Skip to content

Commit

Permalink
Implement FromStr for the ID types (serenity-rs#2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
onlycs authored Aug 20, 2023
1 parent b2393a3 commit 8b2ae0e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/model/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ macro_rules! id_u64 {
id.0 as i64
}
}

impl std::str::FromStr for $name {
type Err = <u64 as std::str::FromStr>::Err;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(s.parse()?))
}
}
)*
}
}
Expand Down

0 comments on commit 8b2ae0e

Please sign in to comment.