File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,34 @@ impl AsciiStr {
28
28
unsafe { mem:: transmute ( & self . slice ) }
29
29
}
30
30
31
+ /// Returns the entire string as slice of `Ascii` characters.
31
32
pub fn as_slice ( & self ) -> & [ Ascii ] {
32
33
& self . slice
33
34
}
34
35
36
+ /// Returns the entire string as mutable slice of `Ascii` characters.
37
+ pub fn as_mut_slice ( & mut self ) -> & mut [ Ascii ] {
38
+ & mut self . slice
39
+ }
40
+
41
+ /// Returns a raw pointer to the `AsciiStr`'s buffer.
42
+ ///
43
+ /// The caller must ensure that the slice outlives the pointer this function returns, or else it
44
+ /// will end up pointing to garbage. Modifying the `AsciiStr` may cause it's buffer to be
45
+ /// reallocated, which would also make any pointers to it invalid.
46
+ pub fn as_ptr ( & self ) -> * const Ascii {
47
+ self . as_slice ( ) . as_ptr ( )
48
+ }
49
+
50
+ /// Returns an unsafe mutable pointer to the `AsciiStr`'s buffer.
51
+ ///
52
+ /// The caller must ensure that the slice outlives the pointer this function returns, or else it
53
+ /// will end up pointing to garbage. Modifying the `AsciiStr` may cause it's buffer to be
54
+ /// reallocated, which would also make any pointers to it invalid.
55
+ pub fn as_mut_ptr ( & mut self ) -> * mut Ascii {
56
+ self . as_mut_slice ( ) . as_mut_ptr ( )
57
+ }
58
+
35
59
/// Copies the content of this `AsciiStr` into an owned `AsciiString`.
36
60
pub fn to_ascii_string ( & self ) -> AsciiString {
37
61
AsciiString :: from ( self . slice . to_vec ( ) )
You can’t perform that action at this time.
0 commit comments