<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/rust/kernel/str.rs, branch v6.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.3</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.3'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2023-04-06T19:55:12Z</updated>
<entry>
<title>rust: str: fix requierments-&gt;requirements typo</title>
<updated>2023-04-06T19:55:12Z</updated>
<author>
<name>Patrick Blass</name>
<email>patrickblass@mailbox.org</email>
</author>
<published>2023-03-03T19:06:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=88e8c2ec4ab84f9f05ed5af9693a3972baf386c4'/>
<id>urn:sha1:88e8c2ec4ab84f9f05ed5af9693a3972baf386c4</id>
<content type='text'>
Fix a trivial spelling error in the `rust/kernel/str.rs` file.

Fixes: 247b365dc8dc ("rust: add `kernel` crate")
Reported-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://github.com/Rust-for-Linux/linux/issues/978
Signed-off-by: Patrick Blass &lt;patrickblass@mailbox.org&gt;
Reviewed-by: Vincenzo Palazzo &lt;vincenzopalazzodev@gmail.com&gt;
[Reworded slightly]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `fmt!` macro</title>
<updated>2022-12-04T00:59:16Z</updated>
<author>
<name>Wedson Almeida Filho</name>
<email>wedsonaf@gmail.com</email>
</author>
<published>2022-11-10T16:41:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ef32054942ee8d78cbcc2c97212e55b6f5f668f7'/>
<id>urn:sha1:ef32054942ee8d78cbcc2c97212e55b6f5f668f7</id>
<content type='text'>
Add the `fmt!` macro, which is a convenience alias for the Rust
`core::format_args!` macro.

For instance, it may be used to create a `CString`:

    CString::try_from_fmt(fmt!("{}{}", "abc", 42))?

Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `CString` type</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Wedson Almeida Filho</name>
<email>wedsonaf@gmail.com</email>
</author>
<published>2022-11-10T16:41:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=65e1e497f6d63f747d453b3d89fbeb6d140cbbb7'/>
<id>urn:sha1:65e1e497f6d63f747d453b3d89fbeb6d140cbbb7</id>
<content type='text'>
Add the `CString` type, which is an owned string that is guaranteed
to have exactly one `NUL` byte at the end, i.e. the owned equivalent
to `CStr` introduced earlier.

It is used for interoperability with kernel APIs that take C strings.

In order to do so, implement the `RawFormatter::new()` constructor
and the `RawFormatter::bytes_written()` method as well.

Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `Formatter` type</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Wedson Almeida Filho</name>
<email>wedsonaf@gmail.com</email>
</author>
<published>2022-11-10T16:41:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fffed679eeea119c8f972954518c142ec95bda4a'/>
<id>urn:sha1:fffed679eeea119c8f972954518c142ec95bda4a</id>
<content type='text'>
Add the `Formatter` type, which leverages `RawFormatter`,
but fails if callers attempt to write more than will fit
in the buffer.

In order to so, implement the `RawFormatter::from_buffer()`
constructor as well.

Co-developed-by: Adam Bratschi-Kaye &lt;ark.email@gmail.com&gt;
Signed-off-by: Adam Bratschi-Kaye &lt;ark.email@gmail.com&gt;
Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `c_str!` macro</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2022-11-10T16:41:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b18cb00e5a8a1182ef491b770ea1a3dab081dc5b'/>
<id>urn:sha1:b18cb00e5a8a1182ef491b770ea1a3dab081dc5b</id>
<content type='text'>
Add `c_str!`, which is a convenience macro that creates a new `CStr`
from a string literal.

It is designed to be similar to a `str` in usage, and it is usable
in const contexts, for instance:

    const X: &amp;CStr = c_str!("Example");

Co-developed-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Signed-off-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `CStr` unit tests</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Milan Landaverde</name>
<email>milan@mdaverde.com</email>
</author>
<published>2022-11-10T16:41:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=985f1f09bf5bf8cbcb43e58a2320de2a5054be4c'/>
<id>urn:sha1:985f1f09bf5bf8cbcb43e58a2320de2a5054be4c</id>
<content type='text'>
Add unit tests for `CStr::from_bytes_with_nul()` and
`CStr::from_bytes_with_nul_unchecked()`.

These serve as an example of the first unit tests for Rust code
(i.e. different from documentation tests).

Signed-off-by: Milan Landaverde &lt;milan@mdaverde.com&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: implement several traits for `CStr`</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2022-11-10T16:41:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c07e67bd2daf99de923b6fd927ab8c18e0f57b05'/>
<id>urn:sha1:c07e67bd2daf99de923b6fd927ab8c18e0f57b05</id>
<content type='text'>
Implement `Debug`, `Display`, `Deref` (into `BStr`), `AsRef&lt;BStr&gt;`
and a set of `Index&lt;...&gt;` traits.

This makes it `CStr` more convenient to use (and closer to `str`).

Co-developed-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Signed-off-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Co-developed-by: Morgan Bartlett &lt;mjmouse9999@gmail.com&gt;
Signed-off-by: Morgan Bartlett &lt;mjmouse9999@gmail.com&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `CStr` type</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2022-11-10T16:41:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d126d2380131dfbc880f5b5f0e3015e9bef6fa1c'/>
<id>urn:sha1:d126d2380131dfbc880f5b5f0e3015e9bef6fa1c</id>
<content type='text'>
Add the `CStr` type, which is a borrowed string that is guaranteed
to have exactly one `NUL` byte, which is at the end.

It is used for interoperability with kernel APIs that take C strings.

Add it to the prelude too.

Co-developed-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Signed-off-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Co-developed-by: Milan Landaverde &lt;milan@mdaverde.com&gt;
Signed-off-by: Milan Landaverde &lt;milan@mdaverde.com&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `b_str!` macro</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2022-11-10T16:41:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=650ec51561fd201bcf47ce9b1d9b6fedd4bb60a6'/>
<id>urn:sha1:650ec51561fd201bcf47ce9b1d9b6fedd4bb60a6</id>
<content type='text'>
Add the `b_str!` macro, which creates a new `BStr` from
a string literal.

It is usable in const contexts, for instance:

    const X: &amp;BStr = b_str!("Example");

Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: str: add `BStr` type</title>
<updated>2022-12-04T00:59:15Z</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2022-11-10T16:41:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7c5977464681c2ec603efcac32a9432bcd355f12'/>
<id>urn:sha1:7c5977464681c2ec603efcac32a9432bcd355f12</id>
<content type='text'>
Add the `BStr` type, which is a byte string without UTF-8
validity guarantee.

It is simply an alias to `[u8]`, but has a more evident
semantical meaning.

Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
</feed>
