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