Skip to content

Instantly share code, notes, and snippets.

@jonathanwork
Created April 11, 2024 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanwork/76a4f4134d40ac2b1e1bed56fa0a18ea to your computer and use it in GitHub Desktop.
Save jonathanwork/76a4f4134d40ac2b1e1bed56fa0a18ea to your computer and use it in GitHub Desktop.
more vec
// this for arrays
fn chaos () -> [i32; 5] {
let mut chaos = [3, 5 ,4, 1, 2];
chaos.sort();
chaos
}
// this is for vectors
fn primes() -> i32 {
let mut primes = vec![2, 3, 5, 7 ] ;
primes.push(11) ;
primes.push(13) ;
primes.iter().product::<i32>()
}
fn new_px_buffer(rows : usize, cols: usize ) -> Vec<u8> {
vec![0; rows * cols]
}
fn main() {
println!("Hello, world!");
println!("{:?}", chaos());
println!("{:?}", primes());
println!("{:?}", new_px_buffer(10 , 10 ))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment