
Rust + Solana Dev in training Building daily. DM to connect.
Blockchain
Joined September 2024
- Tweets502
- Following320
- Followers230
- Likes1.8K
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 !!
🚀 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
🚀 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
🚀 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
🚀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
🚀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🚀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