πŸ“Š Rust
Q. What is the result of the following code?
Code:
fn main() {
    let s = String::from("hello");
    let t = s;
    println!("{}", s);
}
  • (A) hello
  • (B) Compilation error
  • (C) Undefined behavior
  • (D) Nothing
πŸ’¬ Discuss
βœ… Correct Answer: (B) Compilation error

Explanation: Ownership of 's' is moved to 't', so 's' is no longer valid.

Explanation by: Admin
Ownership of 's' is moved to 't', so 's' is no longer valid.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
27
Total Visits
πŸ“½οΈ
3 mo ago
Published
πŸŽ–οΈ
Admin
Publisher
πŸ“ˆ
84%
Success Rate