Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: str: expose `str::{Formatter, RawFormatter}` publicly.

rnull is going to make use of `str::Formatter` and `str::RawFormatter`, so
expose them with public visibility.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://lore.kernel.org/r/20250902-rnull-up-v6-16-v7-3-b5212cc89b98@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Andreas Hindborg and committed by
Jens Axboe
8c5ac71c 87482d6d

+4 -5
+4 -5
rust/kernel/str.rs
··· 736 736 /// 737 737 /// The memory region between `pos` (inclusive) and `end` (exclusive) is valid for writes if `pos` 738 738 /// is less than `end`. 739 - pub(crate) struct RawFormatter { 739 + pub struct RawFormatter { 740 740 // Use `usize` to use `saturating_*` functions. 741 741 beg: usize, 742 742 pos: usize, ··· 794 794 } 795 795 796 796 /// Returns the number of bytes written to the formatter. 797 - pub(crate) fn bytes_written(&self) -> usize { 797 + pub fn bytes_written(&self) -> usize { 798 798 self.pos - self.beg 799 799 } 800 800 } ··· 828 828 /// Allows formatting of [`fmt::Arguments`] into a raw buffer. 829 829 /// 830 830 /// Fails if callers attempt to write more than will fit in the buffer. 831 - pub(crate) struct Formatter<'a>(RawFormatter, PhantomData<&'a mut ()>); 831 + pub struct Formatter<'a>(RawFormatter, PhantomData<&'a mut ()>); 832 832 833 833 impl Formatter<'_> { 834 834 /// Creates a new instance of [`Formatter`] with the given buffer. ··· 843 843 } 844 844 845 845 /// Create a new [`Self`] instance. 846 - #[expect(dead_code)] 847 - pub(crate) fn new(buffer: &mut [u8]) -> Self { 846 + pub fn new(buffer: &mut [u8]) -> Self { 848 847 // SAFETY: `buffer` is valid for writes for the entire length for 849 848 // the lifetime of `Self`. 850 849 unsafe { Formatter::from_buffer(buffer.as_mut_ptr(), buffer.len()) }