Skip to content

Commit

Permalink
allow buffering small values when alloc is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Dec 21, 2023
1 parent 65dd466 commit 6ba7469
Show file tree
Hide file tree
Showing 4 changed files with 1,476 additions and 1,680 deletions.
8 changes: 1 addition & 7 deletions buffer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ enum ErrorKind {
InvalidValue {
reason: &'static str,
},
#[cfg(feature = "alloc")]
OutsideContainer {
method: &'static str,
},
#[cfg(not(feature = "alloc"))]
#[allow(dead_code)]
#[allow(dead_code)] // debug builds never reach this variant
NoAlloc {
method: &'static str,
},
Expand All @@ -35,11 +33,9 @@ impl fmt::Display for Error {
ErrorKind::InvalidValue { reason } => {
write!(f, "the value is invalid: {}", reason)
}
#[cfg(feature = "alloc")]
ErrorKind::OutsideContainer { method } => {
write!(f, "expected a fragment while buffering {}", method)
}
#[cfg(not(feature = "alloc"))]
ErrorKind::NoAlloc { method } => write!(f, "cannot allocate for {}", method),
}
}
Expand All @@ -50,7 +46,6 @@ impl Error {
Error(ErrorKind::Unsupported { actual, expected })
}

#[cfg(feature = "alloc")]
pub(crate) fn outside_container(method: &'static str) -> Self {
Error(ErrorKind::OutsideContainer { method })
}
Expand All @@ -62,7 +57,6 @@ impl Error {
Error(ErrorKind::InvalidValue { reason })
}

#[cfg(not(feature = "alloc"))]
#[track_caller]
pub(crate) fn no_alloc(method: &'static str) -> Self {
/*
Expand Down
Loading

0 comments on commit 6ba7469

Please sign in to comment.