@@ -8,7 +8,10 @@ mod slice_arc;
8
8
#[ cfg( feature = "bytes" ) ]
9
9
mod slice_bytes;
10
10
11
- use std:: sync:: Arc ;
11
+ use std:: {
12
+ path:: { Path , PathBuf } ,
13
+ sync:: Arc ,
14
+ } ;
12
15
13
16
#[ cfg( not( feature = "bytes" ) ) ]
14
17
pub use slice_arc:: Slice ;
@@ -45,6 +48,18 @@ impl From<&String> for Slice {
45
48
}
46
49
}
47
50
51
+ impl From < & Path > for Slice {
52
+ fn from ( value : & Path ) -> Self {
53
+ Self :: from ( value. as_os_str ( ) . as_encoded_bytes ( ) )
54
+ }
55
+ }
56
+
57
+ impl From < PathBuf > for Slice {
58
+ fn from ( value : PathBuf ) -> Self {
59
+ Self :: from ( value. as_os_str ( ) . as_encoded_bytes ( ) )
60
+ }
61
+ }
62
+
48
63
impl From < Arc < str > > for Slice {
49
64
fn from ( value : Arc < str > ) -> Self {
50
65
Self :: from ( & * value)
@@ -161,6 +176,7 @@ mod serde {
161
176
}
162
177
163
178
#[ cfg( test) ]
179
+ #[ allow( clippy:: expect_used) ]
164
180
mod tests {
165
181
use super :: Slice ;
166
182
use std:: { fmt:: Debug , sync:: Arc } ;
@@ -204,7 +220,7 @@ mod tests {
204
220
205
221
// - io::Read
206
222
let reader = std:: io:: Cursor :: new ( vec ! [ 1 , 2 , 3 , 4 ] ) ;
207
- let slice = Slice :: from_reader ( & mut reader. clone ( ) , 4 ) . expect ( "read" ) ;
223
+ let slice = Slice :: from_reader ( & mut reader, 4 ) . expect ( "read" ) ;
208
224
assert_eq ! ( slice, vec![ 1 , 2 , 3 , 4 ] ) ;
209
225
}
210
226
}
0 commit comments