Skip to content

Commit f3ec0fb

Browse files
committed
more docs and clippy
1 parent bab285f commit f3ec0fb

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/fixedwidth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub trait FixedWidthEncoding {
6969
#[derive(Debug)]
7070
pub struct FixedWidthUint<'a, T: FixedWidthEncoding + ?Sized>(&'a T);
7171

72-
impl<'t, T: FixedWidthEncoding> CompactEncoding<T::Decode> for FixedWidthUint<'t, T> {
72+
impl<T: FixedWidthEncoding> CompactEncoding<T::Decode> for FixedWidthUint<'_, T> {
7373
fn encoded_size(&self) -> Result<usize, EncodingError> {
7474
self.0.fw_encoded_size()
7575
}

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,18 @@ pub trait BoxArrayEncodable: CompactEncoding {
290290
/// assert_eq!(result, 12);
291291
/// # Ok::<(), Box<dyn std::error::Error>>(())
292292
/// ```
293+
/// If you want to use this within a non-result context you can do
294+
/// ```
295+
/// # use crate::compact_encoding::{sum_encoded_size, CompactEncoding, EncodingError};
296+
/// let bar = 42u64;
297+
/// let result = (|| { Ok::<usize, EncodingError>(sum_encoded_size!(bar)) })().unwrap();
298+
/// assert_eq!(result, 1);
299+
/// ```
293300
macro_rules! sum_encoded_size {
294301
($($val:expr),+) => {{
295302
let out: usize = [
296303
$(
297304
$val.encoded_size()?,
298-
299305
)*
300306
].iter().sum();
301307
out

0 commit comments

Comments
 (0)