Skip to content

Commit

Permalink
Merge pull request #75 from djmitche/issue51
Browse files Browse the repository at this point in the history
Add From<Bewit> for String
  • Loading branch information
lotas authored Dec 2, 2024
2 parents 5222dd3 + c1837e1 commit 6dedc9b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/bewit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ impl<'a> Bewit<'a> {
}
}

impl<'a> From<Bewit<'a>> for String {
fn from(bewit: Bewit<'a>) -> Self {
bewit.to_str()
}
}

const BACKSLASH: u8 = b'\\';

impl<'a> FromStr for Bewit<'a> {
Expand Down Expand Up @@ -171,6 +177,17 @@ mod test {
assert_eq!(bewit.to_str(), BEWIT_WITH_EXT_STR);
}

#[test]
fn test_from_bewit_for_string() {
let bewit = Bewit::new(
"me",
UNIX_EPOCH + Duration::new(1353832834, 0),
make_mac(),
None,
);
assert_eq!(String::from(bewit), BEWIT_STR);
}

#[test]
fn test_accessors() {
let bewit = Bewit::from_str(BEWIT_STR).unwrap();
Expand Down

0 comments on commit 6dedc9b

Please sign in to comment.