diff --git a/pkstrings/examples/convert.rs b/pkstrings/examples/convert.rs index 001ec86..7e02417 100644 --- a/pkstrings/examples/convert.rs +++ b/pkstrings/examples/convert.rs @@ -29,7 +29,7 @@ fn main() { if args.len() == 2 { // Convert String to PKString and then to Vec - let tmp: Vec = PKString::try_from(args[1].clone()).unwrap().into(); + let tmp: Vec = PKString::try_from(args[1].as_str()).unwrap().into(); println!("{:#02x?}", tmp); } else if args.len() == 3 && args[1] == String::from("rev") { // Consure chars 2 by 2 and convert to u8. diff --git a/pkstrings/examples/strings.rs b/pkstrings/examples/strings.rs index 76b120d..13f367f 100644 --- a/pkstrings/examples/strings.rs +++ b/pkstrings/examples/strings.rs @@ -40,7 +40,7 @@ fn read_data(data: Vec) { for (offset, ord) in data.iter().enumerate() { // Read current chr - if let Ok(pkstr) = PKString::try_from(*ord) { + if let Ok(pkstr) = PKString::try_from(&[*ord][..]) { buffer.push(String::from(pkstr)); } else { if buffer.len() >= 4 { diff --git a/pkstrings/src/pkstring.rs b/pkstrings/src/pkstring.rs index 252a3b4..839195c 100644 --- a/pkstrings/src/pkstring.rs +++ b/pkstrings/src/pkstring.rs @@ -192,14 +192,6 @@ impl TryFrom<&str> for PKString { } } -impl TryFrom for PKString { - type Error = Error; - - fn try_from(data: String) -> Result { - PKString::try_from(data.as_str()) - } -} - impl From for Vec { fn from(pkstr: PKString) -> Vec { pkstr.0 diff --git a/pkstrings/src/tests.rs b/pkstrings/src/tests.rs index 2d0d543..dec6d6b 100644 --- a/pkstrings/src/tests.rs +++ b/pkstrings/src/tests.rs @@ -104,14 +104,6 @@ fn test_into_vec_u8() { assert_eq!(res, GARY_SLICE_U8); } -#[test] -fn test_from_string() { - match PKString::try_from(String::from(GARY_STR)) { - Ok(pkstr) => assert_eq!(pkstr, PKString::try_from(GARY_SLICE_U8).unwrap()), - Err(_) => panic!(), - } -} - #[test] fn test_as_slice_u8() { let pkstr: PKString = PKString::try_from(GARY_SLICE_U8).unwrap();