Skip to content

Commit

Permalink
Fix minor clippy lints mostly around docs
Browse files Browse the repository at this point in the history
  • Loading branch information
barafael committed Aug 31, 2024
1 parent 1859013 commit ba359b1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions source/postcard/src/de/flavors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'de> Flavor<'de> for Slice<'de> {
}
}

/// Support for [std::io] or `embedded-io` traits
/// Support for [`std::io`] or `embedded-io` traits
#[cfg(any(
feature = "embedded-io-04",
feature = "embedded-io-06",
Expand Down Expand Up @@ -248,7 +248,7 @@ pub mod io {
use super::SlidingBuffer;
use crate::{Error, Result};

/// Wrapper over a [`embedded_io`](crate::eio::embedded_io)::[`Read`](crate::eio::Read) and a sliding buffer to implement the [Flavor] trait
/// Wrapper over a [`embedded_io`](crate::eio::embedded_io)::[`Read`](crate::eio::Read) and a sliding buffer to implement the [`Flavor`] trait
pub struct EIOReader<'de, T>
where
T: crate::eio::Read,
Expand Down Expand Up @@ -307,15 +307,15 @@ pub mod io {
}
}

/// Support for [std::io] traits
/// Support for [`std::io`] traits
#[allow(clippy::module_inception)]
#[cfg(feature = "use-std")]
pub mod io {
use super::super::Flavor;
use super::SlidingBuffer;
use crate::{Error, Result};

/// Wrapper over a [std::io::Read] and a sliding buffer to implement the [Flavor] trait
/// Wrapper over a [`std::io::Read`] and a sliding buffer to implement the [Flavor] trait
pub struct IOReader<'de, T>
where
T: std::io::Read,
Expand Down
2 changes: 1 addition & 1 deletion source/postcard/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
Ok((t, deserializer.finalize()?))
}

/// Deserialize a message of type `T` from a [std::io::Read].
/// Deserialize a message of type `T` from a [`std::io::Read`].
#[cfg(feature = "use-std")]
pub fn from_io<'a, T, R>(val: (R, &'a mut [u8])) -> Result<(T, (R, &'a mut [u8]))>
where
Expand Down
6 changes: 3 additions & 3 deletions source/postcard/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use core::fmt::{Display, Formatter};
#[cfg_attr(feature = "use-defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum Error {
/// This is a feature that PostCard will never implement
/// This is a feature that postcard will never implement
WontImplement,
/// This is a feature that Postcard intends to support, but does not yet
/// This is a feature that postcard intends to support, but does not yet
NotYetImplemented,
/// The serialize buffer is full
SerializeBufferFull,
Expand All @@ -25,7 +25,7 @@ pub enum Error {
DeserializeBadUtf8,
/// Found an Option discriminant that wasn't 0 or 1
DeserializeBadOption,
/// Found an enum discriminant that was > u32::max_value()
/// Found an enum discriminant that was > `u32::MAX`
DeserializeBadEnum,
/// The original data was not well encoded
DeserializeBadEncoding,
Expand Down
2 changes: 1 addition & 1 deletion source/postcard/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub enum SdmTy {
/// The `f32` Serde Data Model Type
F32,

/// The `f64 Serde Data Model Type
/// The `f64` Serde Data Model Type
F64,

/// The `char` Serde Data Model Type
Expand Down
30 changes: 15 additions & 15 deletions source/postcard/src/ser/flavors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,18 @@ pub trait Flavor {
/// such as a slice or a Vec of some sort.
type Output;

/// The try_extend() trait method can be implemented when there is a more efficient way of processing
/// multiple bytes at once, such as copying a slice to the output, rather than iterating over one byte
/// at a time.
/// Override this method when you want to customize processing
/// multiple bytes at once, such as copying a slice to the output,
/// rather than iterating over one byte at a time.
#[inline]
fn try_extend(&mut self, data: &[u8]) -> Result<()> {
data.iter().try_for_each(|d| self.try_push(*d))
}

/// The try_push() trait method can be used to push a single byte to be modified and/or stored
/// Push a single byte to be modified and/or stored.
fn try_push(&mut self, data: u8) -> Result<()>;

/// Finalize the serialization process
/// Finalize the serialization process.
fn finalize(self) -> Result<Self::Output>;
}

Expand Down Expand Up @@ -212,7 +212,7 @@ impl<'a> IndexMut<usize> for Slice<'a> {
}
}

/// Wrapper over a [`std::iter::Extend<u8>`] that implements the flavor trait
/// Wrapper over a [`core::iter::Extend<u8>`] that implements the flavor trait
pub struct ExtendFlavor<T> {
iter: T,
}
Expand All @@ -221,7 +221,7 @@ impl<T> ExtendFlavor<T>
where
T: core::iter::Extend<u8>,
{
/// Create a new [Self] flavor from a given [`std::iter::Extend<u8>`]
/// Create a new [`Self`] flavor from a given [`core::iter::Extend<u8>`]
pub fn new(iter: T) -> Self {
Self { iter }
}
Expand All @@ -241,7 +241,7 @@ where

#[inline(always)]
fn try_extend(&mut self, b: &[u8]) -> Result<()> {
self.iter.extend(b.iter().cloned());
self.iter.extend(b.iter().copied());
Ok(())
}

Expand All @@ -266,7 +266,7 @@ pub mod eio {
where
T: crate::eio::Write,
{
/// Create a new [Self] flavor from a given [`embedded_io Write`](crate::eio::Write)
/// Create a new [`Self`] flavor from a given [`embedded_io Write`](crate::eio::Write)
pub fn new(writer: T) -> Self {
Self { writer }
}
Expand Down Expand Up @@ -303,14 +303,14 @@ pub mod eio {
}
}

/// Support for the [std::io] traits
/// Support for the [`std::io`] traits
#[cfg(feature = "use-std")]
pub mod io {

use super::Flavor;
use crate::{Error, Result};

/// Wrapper over a [std::io::Write] that implements the flavor trait
/// Wrapper over a [`std::io::Write`] that implements the flavor trait
pub struct WriteFlavor<T> {
writer: T,
}
Expand All @@ -319,7 +319,7 @@ pub mod io {
where
T: std::io::Write,
{
/// Create a new [Self] flavor from a given [std::io::Write]
/// Create a new [`Self`] flavor from a given [`std::io::Write`]
pub fn new(writer: T) -> Self {
Self { writer }
}
Expand Down Expand Up @@ -377,7 +377,7 @@ mod heapless_vec {
}

impl<const B: usize> HVec<B> {
/// Create a new, currently empty, [heapless::Vec] to be used for storing serialized
/// Create a new, currently empty, [`heapless::Vec`] to be used for storing serialized
/// output data.
pub fn new() -> Self {
Self::default()
Expand Down Expand Up @@ -436,7 +436,7 @@ mod alloc_vec {
use crate::Result;
use alloc::vec::Vec;

/// The `AllocVec` flavor is a wrapper type around an [alloc::vec::Vec].
/// The `AllocVec` flavor is a wrapper type around an [`alloc::vec::Vec`].
///
/// This type is only available when the (non-default) `alloc` feature is active
#[derive(Default)]
Expand All @@ -446,7 +446,7 @@ mod alloc_vec {
}

impl AllocVec {
/// Create a new, currently empty, [alloc::vec::Vec] to be used for storing serialized
/// Create a new, currently empty, [`alloc::vec::Vec`] to be used for storing serialized
/// output data.
pub fn new() -> Self {
Self::default()
Expand Down
4 changes: 2 additions & 2 deletions source/postcard/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ where
)
}

/// Serialize a `T` to a [core::iter::Extend],
/// Serialize a `T` to a [`core::iter::Extend`],
/// ## Example
///
/// ```rust
Expand Down Expand Up @@ -295,7 +295,7 @@ where
serialize_with_flavor::<T, _, _>(value, flavors::eio::WriteFlavor::new(writer))
}

/// Serialize a `T` to a [std::io::Write],
/// Serialize a `T` to a [`std::io::Write`],
/// ## Example
///
/// ```rust
Expand Down
4 changes: 2 additions & 2 deletions source/postcard/src/ser/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ where

// This is the first pass through, where we just count the length of the
// data that we are given
write!(&mut ctr, "{}", value).map_err(|_| Error::CollectStrError)?;
write!(&mut ctr, "{value}").map_err(|_| Error::CollectStrError)?;
let len = ctr.ct;
self.try_push_varint_usize(len)
.map_err(|_| Error::SerializeBufferFull)?;
Expand All @@ -382,7 +382,7 @@ where
let mut fw = FmtWriter {
output: &mut self.output,
};
write!(&mut fw, "{}", value).map_err(|_| Error::CollectStrError)?;
write!(&mut fw, "{value}").map_err(|_| Error::CollectStrError)?;

Ok(())
}
Expand Down

0 comments on commit ba359b1

Please sign in to comment.