expression
Take ownership when a value must retain data
A domain object that stores a title can accept its ownership directly. This makes the transfer explicit and avoids cloning an already owned String. Borrowing would require a lifetime relationship to the caller, which is not the intended contract here. A convenience constructor may accept other inputs when that is genuinely useful. Expected result (NOT RUN): task: review Common mistake: Adding Clone solely to work around an ownership transfer that the API should express. Static Rust example; not a verified ByteMind executable assessment.
Formal Syntax & Structure
rust syntaxrust
fn new(title: String) -> SelfWorking Example
Example Snippetrust
struct Task { title: String }impl Task { fn new(title: String) -> Self { Self { title } } fn title(&self) -> &str { &self.title }}fn main() { let title = String::from("review"); let task = Task::new(title); println!("task: {}", task.title());}