From: LukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com> Date: Tue, 14 May 2024 12:56:22 +0000 (+0200) Subject: Use &str rather than &String X-Git-Url: http://git.euphorik.ch/?a=commitdiff_plain;h=28a1bb94ada020477c559be6352c2cc256f6cb58;p=rust_exercises.git Use &str rather than &String --- diff --git a/book/src/05_ticket_v2/04_if_let.md b/book/src/05_ticket_v2/04_if_let.md index 562f800..1b567c3 100644 --- a/book/src/05_ticket_v2/04_if_let.md +++ b/book/src/05_ticket_v2/04_if_let.md @@ -4,7 +4,7 @@ Your solution to the previous exercise probably looks like this: ```rust impl Ticket { - pub fn assigned_to(&self) -> &String { + pub fn assigned_to(&self) -> &str { match &self.status { Status::InProgress { assigned_to } => assigned_to, Status::Done | Status::ToDo => { @@ -29,7 +29,7 @@ Here's how you can use `if let` to simplify the `assigned_to` method: ```rust impl Ticket { - pub fn assigned_to(&self) -> &String { + pub fn assigned_to(&self) -> &str { if let Status::InProgress { assigned_to } = &self.status { assigned_to } else { @@ -46,7 +46,7 @@ you can use the `let/else` construct: ```rust impl Ticket { - pub fn assigned_to(&self) -> &String { + pub fn assigned_to(&self) -> &str { let Status::InProgress { assigned_to } = &self.status else { panic!("Only `In-Progress` tickets can be assigned to someone"); };