File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ implemented ` AsRef<str> ` and ` AsRef<[u8]> ` for ` PyBackedStr ` , ` AsRef<[u8]> ` for ` PyBackedBytes ` .
Original file line number Diff line number Diff line change @@ -27,6 +27,18 @@ impl Deref for PyBackedStr {
27
27
}
28
28
}
29
29
30
+ impl AsRef < str > for PyBackedStr {
31
+ fn as_ref ( & self ) -> & str {
32
+ self
33
+ }
34
+ }
35
+
36
+ impl AsRef < [ u8 ] > for PyBackedStr {
37
+ fn as_ref ( & self ) -> & [ u8 ] {
38
+ self . as_bytes ( )
39
+ }
40
+ }
41
+
30
42
impl TryFrom < Bound < ' _ , PyString > > for PyBackedStr {
31
43
type Error = PyErr ;
32
44
fn try_from ( py_string : Bound < ' _ , PyString > ) -> Result < Self , Self :: Error > {
@@ -82,6 +94,12 @@ impl Deref for PyBackedBytes {
82
94
}
83
95
}
84
96
97
+ impl AsRef < [ u8 ] > for PyBackedBytes {
98
+ fn as_ref ( & self ) -> & [ u8 ] {
99
+ self
100
+ }
101
+ }
102
+
85
103
impl From < Bound < ' _ , PyBytes > > for PyBackedBytes {
86
104
fn from ( py_bytes : Bound < ' _ , PyBytes > ) -> Self {
87
105
let b = py_bytes. as_bytes ( ) ;
You can’t perform that action at this time.
0 commit comments