Learn Before
Code

Ownership and Variable Binding - Rust Programming

fn main() { let s1 = String::from("hello"); // Ownership of s1 is transferred (moved) to s2 let s2 = s1; // This line would cause a compile error, // as s1 is no longer valid // println!("{}", s1); println!("{}", s2); }

0

1

Updated 2023-04-18

References


Tags

Object-Oriented Programming

Programming Language Paradigms

General programming languages

Computing Sciences