http_path_params/
username.rs1use alloc::string::{String, ToString as _};
2use core::{convert::Infallible, str::FromStr};
3
4#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub struct Username(pub String);
7
8impl core::fmt::Display for Username {
9 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
10 write!(f, "{}", self.0)
11 }
12}
13
14impl FromStr for Username {
15 type Err = Infallible;
16
17 fn from_str(s: &str) -> Result<Self, Self::Err> {
18 Ok(Self(s.to_string()))
19 }
20}