Created
April 11, 2024 06:15
-
-
Save jonathanwork/76a4f4134d40ac2b1e1bed56fa0a18ea to your computer and use it in GitHub Desktop.
more vec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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