Skip to content

Instantly share code, notes, and snippets.

@jonathanwork
Created April 11, 2024 05:49
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/8e0bca80588971f6fd124e00abb15e82 to your computer and use it in GitHub Desktop.
Save jonathanwork/8e0bca80588971f6fd124e00abb15e82 to your computer and use it in GitHub Desktop.
simple rust programs
fn vector() -> Vec<i16> {
let mut v : Vec<i16> =
Vec::<i16>::new() ;
v.push(10i16);
v.push(20i16);
v
}
fn many() {
let mut sieve = [true; 1000] ;
for i in 2..100 {
if sieve[i] {
let mut j = i* i ;
while j < 1000 {
sieve[j] = false;
j += i
}
}
}
println!("{:?}" , sieve)
}
fn main() {
println!("Hello, world!");
let run =
vector();
println!("{run:#?}" );
many() ;
let lazy_caterer: [u32; 6] = [1, 2,3, 4, 5, 6 ] ;
let tax = ["animalia" , "Arthropoda" , "Insecta"];
println!("{}", lazy_caterer[3] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment