Mr. Rust (@code_rusty) header
Mr. Rust (@code_rusty) profile picture

Rust + Solana Dev in training Building daily. DM to connect.

Blockchain
Joined September 2024
Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)Photo by Mr. Rust (@code_rusty)
Published my first CLI tool in Rust: smart_tasker Command-line task tracker using - clap - serde Supports: add, list, complete, delete Published: crates.io/crates/smart_taske… Please check !!
1
1
13
1,143
🚀Question 205: What does this print?🦀 fn main() { let arr = [10, 20, 30]; let mut iter = arr.iter().rev(); println!("{:?}", iter.next()); println!("{:?}", iter.next()); }
11%Some(10) Some(20)
89%Some(30) Some(20)
0%Some(10) None
0%Compile error
18 votes • Final results
1
2
3
291
Q204🦀: fn main() { let s1 = String::from("abc"); let s2 = String::from("defg"); let t = { let r1 = s1.as_str(); let r2 = s2.as_str(); if r1.len() > r2.len() { r1 } else { r2 } }; println!("{}", t); }
22%Compile error
0%Panics
0%abc
78%defg
18 votes • Final results
1
2
295
🚀 Question 203: What is the output? 🦀 fn main() { let s1 = String::from("hi"); let s2 = String::from("rust"); let r: &str; { r = if s1.len() > s2.len() { &s1 } else { &s2 }; } println!("{}", r); }
29%Compile error
14%Panics
48%rust
10%hi
21 votes • Final results
1
227
Q: 202🦀 fn main() { let v = vec![1, 2, 3]; let mut iter = v.into_iter(); println!("{:?}", iter.next()); println!("{:?}", iter.next()); println!("{:?}", iter.next()); println!("{:?}", iter.next()); }
62%Some, Some, Some, None
31%1, 2, 3, panic
8%Compile error
0%None, None, None, None
26 votes • Final results
1
4
242
🚀 Question 201: What does this program print? 🦀 fn main() { let mut s = String::from("rust"); { let r = &mut s; r.push_str("ace"); } println!("{}", s); }
4%Panics
16%rust
57%rustace
23%Compile error
189 votes • Final results
3
12
1,765
Rust macros are black magic wrapped in curly braces.
4
131
🚀 Question 200: What will this print? 🦀 ```rust fn main() { let v = vec![1, 2, 3]; let iter = v.iter(); drop(v); for x in iter { println!("{}", x); } } ```
83%Compile error
7%1 2 3
9%Panics
2%Nothing
58 votes • Final results
1
2
561
Web3 in JavaScript: “ship fast, break things.” Web3 in Rust: “ship once, pray never.”
1
6
887
🚀 Question 199: In Rust, what happens when your landlord sells the house? Do you still get to be the tenant? 🦀 ```rust fn main() { let s1 = String::from("hi"); let s2 = &s1; let s3 = s1; println!("{}", s2); } ```
20%Prints "hi"
73%Compile error
2%Prints ""
6%Panics
106 votes • Final results
10
872
“Why Rust?” Because I like safety… and also pain.
1
10
814
🚀Question 198: What is the output?🦀 fn main() { let data = vec!["a", "bb", "ccc"]; let max = data.iter() .max_by_key ( |s| s.len () ) .unwrap (); println!("{}", max); }
19%Compile error
6%a
1%bb
74%ccc
141 votes • Final results
1
5
1,600
Rust doesn’t have garbage collection. It has you, collecting your own garbage at compile time.
1
29
1,260
🚀Question 197: What happens here?🦀 fn main() { let mut v = vec! [1, 2, 3 ] ; let a = &v[0] ; v.push(4) ; println!("{}", a) ; }
30%Prints 1
7%Prints 4
6%Panics
57%Compile error
176 votes • Final results
2
11
1,541
🚀Question 196: What will be printed?🦀 fn main() { let mut n = 1; let f = || { n += 2; }; f(); println!("{}", n); }
48%Compile error
11%1
4%2
37%3
194 votes • Final results
5
12
2,420
🚀Question 195: What happens?🦀 fn main() { let v = vec![1, 2, 3]; for i in v { println!("{}", i); } println!("{}", v[0]); }
3%Prints 1 then 1
52%Compile error
39%Prints 123 then 1
5%Panics
230 votes • Final results
4
2
14
2,324
🚀Question 194: What is the output?🦀 fn main() { let x = 5; let y = &x; println!("{}", *y + 1); }
24%Compile error
2%5
69%6
5%Runtime panic
149 votes • Final results
1
7
1,333
🚀Question 193: In tokio, what does tokio::spawn return?🦀
2%Result<T>
5%ThreadId
65%JoinHandle
28%Future<()>
60 votes • Final results
1
445
🚀Question 192: In serde_json, what does serde_json::to_string(&value)? return?🦀
16%Vec<u8>
68%JSON string
14%Parsed Value
3%HashMap
37 votes • Final results
328
🚀Question 191: In tokio, what does .await on a future do?🦀
74%Yields until ready
19%Blocks thread
6%Spawns new task
0%Panics if pending
47 votes • Final results
3
319