File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
crates/kernel_cmdline/src Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ impl<'a, T: AsRef<[u8]> + ?Sized> From<&'a T> for Cmdline<'a> {
3030 }
3131}
3232
33+ impl Deref for Cmdline < ' _ > {
34+ type Target = [ u8 ] ;
35+
36+ fn deref ( & self ) -> & Self :: Target {
37+ & self . 0
38+ }
39+ }
40+
3341impl From < Vec < u8 > > for CmdlineOwned {
3442 /// Creates a new `Cmdline` from an owned `Vec<u8>`.
3543 fn from ( input : Vec < u8 > ) -> Self {
Original file line number Diff line number Diff line change @@ -213,6 +213,16 @@ impl<'a> Cmdline<'a> {
213213 }
214214}
215215
216+ impl Deref for Cmdline < ' _ > {
217+ type Target = str ;
218+
219+ fn deref ( & self ) -> & Self :: Target {
220+ // SAFETY: We know this is valid UTF-8 since we only
221+ // construct the underlying `bytes` from valid UTF-8
222+ str:: from_utf8 ( & self . 0 ) . expect ( "We only construct the underlying bytes from valid UTF-8" )
223+ }
224+ }
225+
216226impl < ' a > AsRef < str > for Cmdline < ' a > {
217227 fn as_ref ( & self ) -> & str {
218228 str:: from_utf8 ( self . 0 . as_ref ( ) )
You can’t perform that action at this time.
0 commit comments