diff --git a/crates/kernel_cmdline/src/bytes.rs b/crates/kernel_cmdline/src/bytes.rs index 87698d00..73d06290 100644 --- a/crates/kernel_cmdline/src/bytes.rs +++ b/crates/kernel_cmdline/src/bytes.rs @@ -18,6 +18,9 @@ use anyhow::Result; #[derive(Clone, Debug, Default)] pub struct Cmdline<'a>(Cow<'a, [u8]>); +/// An owned Cmdline. Alias for `Cmdline<'static>`. +pub type CmdlineOwned = Cmdline<'static>; + impl<'a, T: AsRef<[u8]> + ?Sized> From<&'a T> for Cmdline<'a> { /// Creates a new `Cmdline` from any type that can be referenced as bytes. /// @@ -27,7 +30,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> From<&'a T> for Cmdline<'a> { } } -impl<'a> From> for Cmdline<'a> { +impl From> for CmdlineOwned { /// Creates a new `Cmdline` from an owned `Vec`. fn from(input: Vec) -> Self { Self(Cow::Owned(input)) @@ -85,7 +88,7 @@ impl<'a> Cmdline<'a> { /// Creates a new empty owned `Cmdline`. /// /// This is equivalent to `Cmdline::default()` but makes ownership explicit. - pub fn new() -> Cmdline<'static> { + pub fn new() -> CmdlineOwned { Cmdline::default() } @@ -670,8 +673,8 @@ mod tests { assert_eq!(kargs.iter().next(), None); assert!(kargs.is_owned()); - // Verify we can store it in a 'static context - let _static_kargs: Cmdline<'static> = Cmdline::new(); + // Verify we can store it in an owned ('static) context + let _static_kargs: CmdlineOwned = Cmdline::new(); } #[test] diff --git a/crates/kernel_cmdline/src/utf8.rs b/crates/kernel_cmdline/src/utf8.rs index 72e27be3..5403154b 100644 --- a/crates/kernel_cmdline/src/utf8.rs +++ b/crates/kernel_cmdline/src/utf8.rs @@ -17,6 +17,9 @@ use anyhow::Result; #[derive(Clone, Debug, Default)] pub struct Cmdline<'a>(bytes::Cmdline<'a>); +/// An owned `Cmdline`. Alias for `Cmdline<'static>`. +pub type CmdlineOwned = Cmdline<'static>; + impl<'a, T: AsRef + ?Sized> From<&'a T> for Cmdline<'a> { /// Creates a new `Cmdline` from any type that can be referenced as `str`. /// @@ -26,7 +29,7 @@ impl<'a, T: AsRef + ?Sized> From<&'a T> for Cmdline<'a> { } } -impl From for Cmdline<'static> { +impl From for CmdlineOwned { /// Creates a new `Cmdline` from a `String`. /// /// Takes ownership of input and maintains it for internal owned data. @@ -72,7 +75,7 @@ impl<'a> Cmdline<'a> { /// Creates a new empty owned `Cmdline`. /// /// This is equivalent to `Cmdline::default()` but makes ownership explicit. - pub fn new() -> Cmdline<'static> { + pub fn new() -> CmdlineOwned { Cmdline::default() } @@ -577,8 +580,8 @@ mod tests { assert_eq!(kargs.iter().next(), None); assert!(kargs.is_owned()); - // Verify we can store it in a 'static context - let _static_kargs: Cmdline<'static> = Cmdline::new(); + // Verify we can store it in an owned ('static) context + let _static_kargs: CmdlineOwned = Cmdline::new(); } #[test]