From 596e7566a7efaf078de228a7c49953bf192531a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dahlstr=C3=B6m?= Date: Fri, 29 Nov 2024 21:45:36 +0200 Subject: [PATCH] Make buf::inner public Needed to make the Inner interface visible in docs. --- Cargo.toml | 2 +- core/src/util/buf.rs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 49660aa5..d7afceeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ resolver = "2" [workspace.package] edition = "2021" -version = "0.3.0" +version = "0.3.2" authors = ["Johannes 'Sharlin' Dahlström "] license = "MIT OR Apache-2.0" repository = "https://github.com/jdahlstrom/retrofire" diff --git a/core/src/util/buf.rs b/core/src/util/buf.rs index 36da9b22..c3385070 100644 --- a/core/src/util/buf.rs +++ b/core/src/util/buf.rs @@ -278,7 +278,7 @@ impl<'a, T> DerefMut for MutSlice2<'a, T> { } } -mod inner { +pub mod inner { use core::fmt::Formatter; use core::marker::PhantomData; use core::ops::{Deref, DerefMut, Index, IndexMut, Range}; @@ -290,6 +290,7 @@ mod inner { use super::{AsSlice2, MutSlice2, Slice2}; /// A helper type that abstracts over owned and borrowed buffers. + /// /// The types `Buf2`, `Slice2`, and `MutSlice2` deref to `Inner`. #[derive(Copy, Clone)] pub struct Inner { @@ -435,6 +436,7 @@ mod inner { } /// Returns an iterator over the rows of `self` as `&[T]` slices. + /// /// The length of each slice equals [`self.width()`](Self::width). pub fn rows(&self) -> impl Iterator { self.data @@ -442,9 +444,10 @@ mod inner { .map(|row| &row[..self.dims.0 as usize]) } - /// Returns an iterator over all the elements of `self` in row-major - /// order: first the elements on row 0 from left to right, followed - /// by the elements on row 1, and so on. + /// Returns an iterator over all the elements of `self` in row-major order. + /// + /// First returns the elements on row 0 from left to right, followed by the elements + /// on row 1, and so on. pub fn iter(&self) -> impl Iterator { self.rows().flatten() } @@ -455,11 +458,14 @@ mod inner { pub fn as_mut_slice2(&mut self) -> MutSlice2 { MutSlice2::new(self.dims, self.stride, &mut self.data) } + /// Returns the data of `self` as a single mutable slice. pub(super) fn data_mut(&mut self) -> &mut [T] { &mut self.data } - /// Returns an iterator over the rows of this buffer as &mut [T]. + + /// Returns an iterator over the rows of this buffer as `&mut [T]`. + /// /// The length of each slice equals [`self.width()`](Self::width). pub fn rows_mut(&mut self) -> impl Iterator { self.data