lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <m2ikopjbm0.fsf@kloenk.dev>
Date: Tue, 04 Mar 2025 12:09:43 +0100
From: Fiona Behrens <me@...enk.dev>
To: Andreas Hindborg <a.hindborg@...nel.org>
Cc: Miguel Ojeda <ojeda@...nel.org>,  Alex Gaynor <alex.gaynor@...il.com>,
  Boqun Feng <boqun.feng@...il.com>,  Gary Guo <gary@...yguo.net>,
  Björn
 Roy Baron <bjorn3_gh@...tonmail.com>,  Benno Lossin
 <benno.lossin@...ton.me>,  Alice Ryhl <aliceryhl@...gle.com>,  Masahiro
 Yamada <masahiroy@...nel.org>,  Nathan Chancellor <nathan@...nel.org>,
  Nicolas Schier <nicolas@...sle.eu>,  Luis Chamberlain
 <mcgrof@...nel.org>,  Trevor Gross <tmgross@...ch.edu>,  Adam
 Bratschi-Kaye <ark.email@...il.com>,  rust-for-linux@...r.kernel.org,
  linux-kernel@...r.kernel.org,  linux-kbuild@...r.kernel.org,  Petr Pavlu
 <petr.pavlu@...e.com>,  Sami Tolvanen <samitolvanen@...gle.com>,  Daniel
 Gomez <da.gomez@...sung.com>,  Simona Vetter <simona.vetter@...ll.ch>,
  Greg KH <gregkh@...uxfoundation.org>,  Daniel Almeida
 <daniel.almeida@...labora.com>,  linux-modules@...r.kernel.org
Subject: Re: [PATCH v8 3/7] rust: str: implement `AsRef<BStr>` for `[u8]`
 and `BStr`

Andreas Hindborg <a.hindborg@...nel.org> writes:

> Implement `AsRef<BStr>` for `[u8]` and `BStr` so these can be used
> interchangeably for operations on `BStr`.
>
> Reviewed-by: Gary Guo <gary@...yguo.net>
> Tested-by: Daniel Almeida <daniel.almeida@...labora.com>
> Reviewed-by: Daniel Almeida <daniel.almeida@...labora.com>
> Signed-off-by: Andreas Hindborg <a.hindborg@...nel.org>

Reviewed-by: Fiona Behrens <me@...enk.dev>

> ---
>  rust/kernel/str.rs | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
> index ba6b1a5c4f99..c6bd2c69543d 100644
> --- a/rust/kernel/str.rs
> +++ b/rust/kernel/str.rs
> @@ -125,6 +125,18 @@ fn index(&self, index: Idx) -> &Self::Output {
>      }
>  }
>  
> +impl AsRef<BStr> for [u8] {
> +    fn as_ref(&self) -> &BStr {
> +        BStr::from_bytes(self)
> +    }
> +}
> +
> +impl AsRef<BStr> for BStr {
> +    fn as_ref(&self) -> &BStr {
> +        self
> +    }
> +}
> +
>  /// Creates a new [`BStr`] from a string literal.
>  ///
>  /// `b_str!` converts the supplied string literal to byte string, so non-ASCII

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ