@@ -83,7 +83,7 @@ impl GStr {
83
83
/// This function is the equivalent of [`GStr::to_bytes`] except that it will retain the
84
84
/// trailing nul terminator instead of chopping it off.
85
85
#[ inline]
86
- pub fn to_bytes_with_nul ( & self ) -> & [ u8 ] {
86
+ pub fn as_bytes_with_nul ( & self ) -> & [ u8 ] {
87
87
self . 0 . as_bytes ( )
88
88
}
89
89
// rustdoc-stripper-ignore-next
@@ -92,7 +92,7 @@ impl GStr {
92
92
/// The returned slice will **not** contain the trailing nul terminator that this GLib
93
93
/// string has.
94
94
#[ inline]
95
- pub fn to_bytes ( & self ) -> & [ u8 ] {
95
+ pub fn as_bytes ( & self ) -> & [ u8 ] {
96
96
self . as_str ( ) . as_bytes ( )
97
97
}
98
98
// rustdoc-stripper-ignore-next
@@ -121,7 +121,7 @@ impl GStr {
121
121
/// Converts this GLib string to a C string slice.
122
122
#[ inline]
123
123
pub fn as_c_str ( & self ) -> & CStr {
124
- unsafe { CStr :: from_bytes_with_nul_unchecked ( self . to_bytes_with_nul ( ) ) }
124
+ unsafe { CStr :: from_bytes_with_nul_unchecked ( self . as_bytes_with_nul ( ) ) }
125
125
}
126
126
127
127
#[ doc( alias = "g_utf8_collate" ) ]
@@ -144,7 +144,7 @@ impl GStr {
144
144
/// use glib::{gstr, GStr, GString};
145
145
///
146
146
/// const MY_STRING: &GStr = gstr!("Hello");
147
- /// assert_eq!(MY_STRING.to_bytes_with_nul ()[5], 0u8);
147
+ /// assert_eq!(MY_STRING.as_bytes_with_nul ()[5], 0u8);
148
148
/// let owned: GString = MY_STRING.to_owned();
149
149
/// assert_eq!(MY_STRING, owned);
150
150
/// # }
@@ -273,7 +273,7 @@ impl AsRef<Path> for GStr {
273
273
274
274
impl AsRef < [ u8 ] > for GStr {
275
275
fn as_ref ( & self ) -> & [ u8 ] {
276
- self . to_bytes ( )
276
+ self . as_bytes ( )
277
277
}
278
278
}
279
279
0 commit comments