Skip to content

Commit 8c5ac71

Browse files
Andreas Hindborgaxboe
authored andcommitted
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>
1 parent 87482d6 commit 8c5ac71

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

rust/kernel/str.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ mod tests {
736736
///
737737
/// The memory region between `pos` (inclusive) and `end` (exclusive) is valid for writes if `pos`
738738
/// is less than `end`.
739-
pub(crate) struct RawFormatter {
739+
pub struct RawFormatter {
740740
// Use `usize` to use `saturating_*` functions.
741741
beg: usize,
742742
pos: usize,
@@ -794,7 +794,7 @@ impl RawFormatter {
794794
}
795795

796796
/// Returns the number of bytes written to the formatter.
797-
pub(crate) fn bytes_written(&self) -> usize {
797+
pub fn bytes_written(&self) -> usize {
798798
self.pos - self.beg
799799
}
800800
}
@@ -828,7 +828,7 @@ impl fmt::Write for RawFormatter {
828828
/// Allows formatting of [`fmt::Arguments`] into a raw buffer.
829829
///
830830
/// 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 ()>);
832832

833833
impl Formatter<'_> {
834834
/// Creates a new instance of [`Formatter`] with the given buffer.
@@ -843,8 +843,7 @@ impl Formatter<'_> {
843843
}
844844

845845
/// 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 {
848847
// SAFETY: `buffer` is valid for writes for the entire length for
849848
// the lifetime of `Self`.
850849
unsafe { Formatter::from_buffer(buffer.as_mut_ptr(), buffer.len()) }

0 commit comments

Comments
 (0)