Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix importing RingBufferSize without alloc feature #120

Merged
merged 4 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Rust

on: [push]
on:
pull_request:
push:

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -111,3 +113,22 @@ jobs:
with:
command: build
args: --target thumbv7em-none-eabihf --all-features

build-without-alloc:
name: Build no-std without alloc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install stable no-std toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: thumbv7em-none-eabihf
override: true

- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --target thumbv7em-none-eabihf --no-default-features
8 changes: 4 additions & 4 deletions src/with_alloc/alloc_ringbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ unsafe impl<T: Send> Send for AllocRingBuffer<T> {}
impl<T, const N: usize> From<[T; N]> for AllocRingBuffer<T, NonPowerOfTwo> {
fn from(value: [T; N]) -> Self {
let mut rb = Self::with_capacity_non_power_of_two(value.len());
rb.extend(value.into_iter());
rb.extend(value);
rb
}
}
Expand Down Expand Up @@ -148,23 +148,23 @@ impl<T: Clone, const CAP: usize> From<&mut [T; CAP]> for AllocRingBuffer<T, NonP
impl<T> From<alloc::vec::Vec<T>> for AllocRingBuffer<T, NonPowerOfTwo> {
fn from(value: alloc::vec::Vec<T>) -> Self {
let mut res = AllocRingBuffer::with_capacity_non_power_of_two(value.len());
res.extend(value.into_iter());
res.extend(value);
res
}
}

impl<T> From<alloc::collections::VecDeque<T>> for AllocRingBuffer<T, NonPowerOfTwo> {
fn from(value: alloc::collections::VecDeque<T>) -> Self {
let mut res = AllocRingBuffer::with_capacity_non_power_of_two(value.len());
res.extend(value.into_iter());
res.extend(value);
res
}
}

impl<T> From<alloc::collections::LinkedList<T>> for AllocRingBuffer<T, NonPowerOfTwo> {
fn from(value: alloc::collections::LinkedList<T>) -> Self {
let mut res = AllocRingBuffer::with_capacity_non_power_of_two(value.len());
res.extend(value.into_iter());
res.extend(value);
res
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/with_alloc/vecdeque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ impl<T: Clone, const CAP: usize> From<&mut [T; CAP]> for GrowableAllocRingBuffer
impl<T> From<alloc::vec::Vec<T>> for GrowableAllocRingBuffer<T> {
fn from(value: alloc::vec::Vec<T>) -> Self {
let mut res = GrowableAllocRingBuffer::new();
res.extend(value.into_iter());
res.extend(value);
res
}
}

impl<T> From<alloc::collections::LinkedList<T>> for GrowableAllocRingBuffer<T> {
fn from(value: alloc::collections::LinkedList<T>) -> Self {
let mut res = GrowableAllocRingBuffer::new();
res.extend(value.into_iter());
res.extend(value);
res
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/with_const_generics.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::ringbuffer_trait::{RingBufferIntoIterator, RingBufferIterator, RingBufferMutIterator};
use crate::with_alloc::alloc_ringbuffer::RingbufferSize;
use crate::RingBuffer;
use core::iter::FromIterator;
use core::mem;
use core::mem::MaybeUninit;
use core::ops::{Index, IndexMut};

#[cfg(feature = "alloc")]
use crate::with_alloc::alloc_ringbuffer::RingbufferSize;

/// The `ConstGenericRingBuffer` struct is a `RingBuffer` implementation which does not require `alloc` but
/// uses const generics instead.
///
Expand Down