[ Prev ]
2021-10-06

-- Oct 6 In-Class Exercise Thread
Original fn main(){ let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } Output s1 = hi there, s2 = hi there Modified fn main(){ let s1 = String::from("hi there"); let s2 = s1; println!("s1 = {}, s2 = {}", s1, s2); } Output error[E0382]: borrow of moved value: `s1` --> src/main.rs:4:31 | 2 | let s1 = String::from("hi there"); | -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait 3 | let s2 = s1; | -- value moved here 4 | println!("s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move
(Edited: 2021-10-06)
<nowiki> Original fn main(){ let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } Output s1 = hi there, s2 = hi there Modified fn main(){ let s1 = String::from("hi there"); let s2 = s1; println!("s1 = {}, s2 = {}", s1, s2); } Output error[E0382]: borrow of moved value: @BT@s1@BT@ --> src/main.rs:4:31 | 2 | let s1 = String::from("hi there"); | -- move occurs because @BT@s1@BT@ has type @BT@String@BT@, which does not implement the @BT@Copy@BT@ trait 3 | let s2 = s1; | -- value moved here 4 | println!("s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move </nowiki>

-- Oct 6 In-Class Exercise Thread
fn main() {
  let s1 = String::from("hi there");
  let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work
  println!("s1 = {}, s2 = {}", s1, s2);
 }
 
 output:
 s1 = hi there, s2 = hi there
 
 fn main() {
  let s1 = String::from("hi there");
  let s2 = s1; // if had let s2 = s1; instead, next line would not work
  println!("s1 = {}, s2 = {}", s1, s2);
 }
 
 output: 
 error[E0382]: borrow of moved value: `s1`
  --> src/main.rs:4:30
   |
 2 | let s1 = String::from("hi there");
   |     -- move occurs because `s1` has type `String`, which does not implement the 
 `Copy` trait
 3 | let s2 = s1; // if had let s2 = s1; instead, next line would not work
   |          -- value moved here
 4 | println!("s1 = {}, s2 = {}", s1, s2);
   |                              ^^ value borrowed here after move 
fn main() { let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } output: s1 = hi there, s2 = hi there fn main() { let s1 = String::from("hi there"); let s2 = s1; // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } output: error[E0382]: borrow of moved value: @BT@s1@BT@ --> src/main.rs:4:30 | 2 | let s1 = String::from("hi there"); | -- move occurs because @BT@s1@BT@ has type @BT@String@BT@, which does not implement the @BT@Copy@BT@ trait 3 | let s2 = s1; // if had let s2 = s1; instead, next line would not work | -- value moved here 4 | println!("s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move
2021-10-09

-- Oct 6 In-Class Exercise Thread
fn main() {
    let s1 = String::from("hi there");
    let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work
    println!("s1 = {}, s2 = {}", s1, s2);
} Output: s1 = hi there, s2 = hi there Edited: fn main() {
    let s1 = String::from("hi there");
    let s2 = s1; // if had let s2 = s1; instead, next line would not work
    println!("s1 = {}, s2 = {}", s1, s2);
} Output: error[E0382]: borrow of moved value: `s1`
 --> rustICA10_6.rs:5:34
  |
3 | let s1 = String::from("hi there");
  |         -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait
4 | let s2 = s1; // if had let s2 = s1; instead, next line would not work
  |              -- value moved here
5 | println!("s1 = {}, s2 = {}", s1, s2);
  |                                  ^^ value borrowed here after move
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.
fn main() { let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } '''Output:''' s1 = hi there, s2 = hi there '''Edited:''' fn main() { let s1 = String::from("hi there"); let s2 = s1; // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } '''Output:''' error[E0382]: borrow of moved value: @BT@s1@BT@ --> rustICA10_6.rs:5:34 | 3 | let s1 = String::from("hi there"); | -- move occurs because @BT@s1@BT@ has type @BT@String@BT@, which does not implement the @BT@Copy@BT@ trait 4 | let s2 = s1; // if had let s2 = s1; instead, next line would not work | -- value moved here 5 | println!("s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move error: aborting due to previous error For more information about this error, try @BT@rustc --explain E0382@BT@.

-- Oct 6 In-Class Exercise Thread
fn main(){
	let s1 = String::from("hi there");
	let s2 = s1;
	println!("s1 = {}, s2 = {}", s1, s2);
}    error[E0382]: borrow of moved value: `s1`   --> main.rs:22:31    | 20 |     let s1 = String::from("hi there");    |         -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait 21 |     let s2 = s1;    |              -- value moved here 22 |     println!("s1 = {}, s2 = {}", s1, s2);    |                                  ^^ value borrowed here after move    error: aborting due to previous error    For more information about this error, try `rustc --explain E0382`.    (Edited: 2021-10-10)
<pre> fn main(){ let s1 = String::from("hi there"); let s2 = s1; println!("s1 = {}, s2 = {}", s1, s2); } error[E0382]: borrow of moved value: @BT@s1@BT@ --> main.rs:22:31 | 20 | let s1 = String::from("hi there"); | -- move occurs because @BT@s1@BT@ has type @BT@String@BT@, which does not implement the @BT@Copy@BT@ trait 21 | let s2 = s1; | -- value moved here 22 | println!("s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move error: aborting due to previous error For more information about this error, try @BT@rustc --explain E0382@BT@. </pre>
2021-10-11

-- Oct 6 In-Class Exercise Thread
fn main() {
    let s1 = String::from("hi there");
    let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work
    println!("Result: s1 = {}, s2 = {}", s1, s2);
}
output: Result: s1 = hi there, s2 = hi there luksaweephansri@Luksawees-MacBookProIntel2021 testR %
fn main() {
    let s1 = String::from("hi there");
    let s2 = s1; // if had let s2 = s1; instead, next line would not work
    println!("Result: s1 = {}, s2 = {}", s1, s2);
}
output: error[E0382]: borrow of moved value: `s1`
 --> src/main.rs:4:42
  |
2 | let s1 = String::from("hi there");
  |         -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait
3 | let s2 = s1; // if had let s2 = s1; instead, next line would not work
  |              -- value moved here
4 | println!("Result: s1 = {}, s2 = {}", s1, s2);
  |                                          ^^ value borrowed here after move
For more information about this error, try `rustc --explain E0382`. error: could not compile `testR` due to previous error
(Edited: 2021-10-11)
fn main() { let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work println!("Result: s1 = {}, s2 = {}", s1, s2); } output: Result: s1 = hi there, s2 = hi there luksaweephansri@Luksawees-MacBookProIntel2021 testR % fn main() { let s1 = String::from("hi there"); let s2 = s1; // if had let s2 = s1; instead, next line would not work println!("Result: s1 = {}, s2 = {}", s1, s2); } output: error[E0382]: borrow of moved value: @BT@s1@BT@ --> src/main.rs:4:42 | 2 | let s1 = String::from("hi there"); | -- move occurs because @BT@s1@BT@ has type @BT@String@BT@, which does not implement the @BT@Copy@BT@ trait 3 | let s2 = s1; // if had let s2 = s1; instead, next line would not work | -- value moved here 4 | println!("Result: s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move For more information about this error, try @BT@rustc --explain E0382@BT@. error: could not compile @BT@testR@BT@ due to previous error

-- Oct 6 In-Class Exercise Thread
 let s1 = String::from("hi there");
  let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work
  println!("s1 = {}, s2 = {}", s1, s2);
 }
 
 output:
 s1 = hi there, s2 = hi there
 
 fn main() {
  let s1 = String::from("hi there");
  let s2 = s1; // if had let s2 = s1; instead, next line would not work
  println!("s1 = {}, s2 = {}", s1, s2);
 }
 
 output: 
 error[E0382]: borrow of moved value: `s1`
  --> src/main.rs:4:30
   |
 2 |let s1 = String::from("hi there");
   |-- move occurs because `s1` has type `String`, which does not implement the 
   |  Copy' trait
 3 | let s2 = s1; // if had let s2 = s1; instead, next line would not work
   |          -- value moved here
 4 | println!("s1 = {}, s2 = {}", s1, s2);
   |                              ^^ value borrowed here after move
let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } output: s1 = hi there, s2 = hi there fn main() { let s1 = String::from("hi there"); let s2 = s1; // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } output: error[E0382]: borrow of moved value: @BT@s1@BT@ --> src/main.rs:4:30 | 2 |let s1 = String::from("hi there"); |-- move occurs because @BT@s1@BT@ has type @BT@String@BT@, which does not implement the | Copy' trait 3 | let s2 = s1; // if had let s2 = s1; instead, next line would not work | -- value moved here 4 | println!("s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move

-- Oct 6 In-Class Exercise Thread
input: fn main(){
  let s1 = String::from("hi there");
  let s2 = s1.clone();
  println!("s1 = {}, s2 = {}", s1, s2);
}
output: s1 = hi there, s2 = hi there
fn main(){
  let s1 = String::from("hi there");
  s2 = s1;
  println!("s1 = {}, s2 = {}", s1, s2);
}
Output: error[E0382]: borrow of moved value: s1
(Edited: 2021-10-11)
input: fn main(){ let s1 = String::from("hi there"); let s2 = s1.clone(); println!("s1 = {}, s2 = {}", s1, s2); } output: s1 = hi there, s2 = hi there fn main(){ let s1 = String::from("hi there"); s2 = s1; println!("s1 = {}, s2 = {}", s1, s2); } Output: error[E0382]: borrow of moved value: s1

-- Oct 6 In-Class Exercise Thread
PROGRAM 1
----- fn main() { let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work
            println!("s1 = {}, s2 = {}", s1, s2);
}
Last login: Mon Oct 11 14:04:28 on ttys001 ~> cd Desktop ~/Desktop> rustc rust.rs ~/Desktop> ./rust s1 = hi there, s2 = hi there
PROGRAM 2
----- fn main() {
	let s1 = String::from("hi there");
	let s2 = s1;
	println!("s1 = {}, s2 = {}", s1, s2);
}
~/Desktop> rustc rust.rs error[E0382]: borrow of moved value: `s1`
 --> rust.rs:4:31
  |
2 | let s1 = String::from("hi there");
  |         -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait
3 | let s2 = s1;
  |              -- value moved here
4 | println!("s1 = {}, s2 = {}", s1, s2);
  |                                  ^^ value borrowed here after move
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.
PROGRAM 1 --------- fn main() { let s1 = String::from("hi there"); let s2 = s1.clone(); // if had let s2 = s1; instead, next line would not work println!("s1 = {}, s2 = {}", s1, s2); } Last login: Mon Oct 11 14:04:28 on ttys001 ~> cd Desktop ~/Desktop> rustc rust.rs ~/Desktop> ./rust s1 = hi there, s2 = hi there PROGRAM 2 --------- fn main() { let s1 = String::from("hi there"); let s2 = s1; println!("s1 = {}, s2 = {}", s1, s2); } ~/Desktop> rustc rust.rs error[E0382]: borrow of moved value: @BT@s1@BT@ --> rust.rs:4:31 | 2 | let s1 = String::from("hi there"); | -- move occurs because @BT@s1@BT@ has type @BT@String@BT@, which does not implement the @BT@Copy@BT@ trait 3 | let s2 = s1; | -- value moved here 4 | println!("s1 = {}, s2 = {}", s1, s2); | ^^ value borrowed here after move error: aborting due to previous error For more information about this error, try @BT@rustc --explain E0382@BT@.
X