Skip to content

Commit 6dedc9b

Browse files
authored
Merge pull request #75 from djmitche/issue51
Add From<Bewit> for String
2 parents 5222dd3 + c1837e1 commit 6dedc9b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bewit.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ impl<'a> Bewit<'a> {
7474
}
7575
}
7676

77+
impl<'a> From<Bewit<'a>> for String {
78+
fn from(bewit: Bewit<'a>) -> Self {
79+
bewit.to_str()
80+
}
81+
}
82+
7783
const BACKSLASH: u8 = b'\\';
7884

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

180+
#[test]
181+
fn test_from_bewit_for_string() {
182+
let bewit = Bewit::new(
183+
"me",
184+
UNIX_EPOCH + Duration::new(1353832834, 0),
185+
make_mac(),
186+
None,
187+
);
188+
assert_eq!(String::from(bewit), BEWIT_STR);
189+
}
190+
174191
#[test]
175192
fn test_accessors() {
176193
let bewit = Bewit::from_str(BEWIT_STR).unwrap();

0 commit comments

Comments
 (0)