Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions exercises/05_ticket_v2/15_outro/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ impl TryFrom<String> for Status {
type Error = ParseStatusError;

fn try_from(value: String) -> Result<Self, Self::Error> {
value.try_into()
}
}

impl TryFrom<&str> for Status {
type Error = ParseStatusError;

fn try_from(value: &str) -> Result<Self, Self::Error> {
let value = value.to_lowercase();
match value.as_str() {
"todo" => Ok(Status::ToDo),
Expand All @@ -24,14 +32,6 @@ impl TryFrom<String> for Status {
}
}

impl TryFrom<&str> for Status {
type Error = ParseStatusError;

fn try_from(value: &str) -> Result<Self, Self::Error> {
value.to_lowercase().try_into()
}
}

#[derive(Debug, thiserror::Error)]
#[error("`{invalid_status}` is not a valid status. Use one of: ToDo, InProgress, Done")]
pub struct ParseStatusError {
Expand Down