pkstrings: new as_slice method
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
7817909a69
commit
31290b2bbc
2 changed files with 11 additions and 12 deletions
|
@ -222,8 +222,8 @@ impl From<PKString> for String {
|
|||
}
|
||||
}
|
||||
|
||||
// impl PKString {
|
||||
// fn as_slice(&self) -> &[u8] {
|
||||
// self.0.as_slice()
|
||||
// }
|
||||
// }
|
||||
impl PKString {
|
||||
pub fn as_slice(&self) -> &[u8] {
|
||||
self.0.as_slice()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,10 +112,9 @@ fn test_from_string() {
|
|||
}
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn test_as_slice_u8() {
|
||||
// let gary: Vec<u8> = vec![0x86, 0x80, 0x91, 0x98];
|
||||
// let pkstr: PKString = PKString::try_from(gary.clone()).unwrap();
|
||||
// let res: &[u8] = pkstr.as_slice();
|
||||
// assert_eq!(res, gary.as_slice());
|
||||
// }
|
||||
#[test]
|
||||
fn test_as_slice_u8() {
|
||||
let pkstr: PKString = PKString::try_from(GARY_SLICE_U8).unwrap();
|
||||
let res: &[u8] = pkstr.as_slice();
|
||||
assert_eq!(res, GARY_SLICE_U8);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue