Skip to content

Commit

Permalink
Support buffering simple values without alloc (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus authored Dec 21, 2023
1 parent 65dd466 commit e681eb3
Show file tree
Hide file tree
Showing 5 changed files with 1,635 additions and 1,700 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/buffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,23 @@ jobs:
- name: Powerset
working-directory: ./buffer
run: cargo hack check --each-feature --exclude-features std,alloc -Z avoid-dev-deps --target thumbv6m-none-eabi

miri:
name: Test (Miri)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: Install Miri
run: |
rustup toolchain install nightly --component miri
cargo +nightly miri setup
- name: Default features
working-directory: ./buffer
run: cargo +nightly miri test --lib

- name: No features
working-directory: ./buffer
run: cargo +nightly miri test --lib --no-default-features
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 e681eb3

Please sign in to comment.