The collections crate was merged into the alloc crate
This commit is contained in:
parent
21483da56b
commit
9db51c3194
|
@ -10,11 +10,7 @@ matrix:
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: FEATURES='alloc'
|
env: FEATURES='alloc'
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: FEATURES='collections'
|
env: FEATURES='std alloc'
|
||||||
- rust: nightly
|
|
||||||
env: FEATURES='alloc collections'
|
|
||||||
- rust: nightly
|
|
||||||
env: FEATURES='std alloc collections'
|
|
||||||
script:
|
script:
|
||||||
- cargo build --no-default-features --features "$FEATURES"
|
- cargo build --no-default-features --features "$FEATURES"
|
||||||
notifications:
|
notifications:
|
||||||
|
|
|
@ -14,5 +14,4 @@ license = "0BSD"
|
||||||
[features]
|
[features]
|
||||||
std = []
|
std = []
|
||||||
alloc = []
|
alloc = []
|
||||||
collections = []
|
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|
|
@ -72,14 +72,9 @@ The `std` feature enables use of `Box` and `Vec` through a dependency on the `st
|
||||||
|
|
||||||
### Feature `alloc`
|
### Feature `alloc`
|
||||||
|
|
||||||
The `alloc` feature enables use of `Box` through a dependency on the `alloc` crate.
|
The `alloc` feature enables use of `Box` and `Vec` through a dependency on the `alloc` crate.
|
||||||
This only works on nightly rustc.
|
This only works on nightly rustc.
|
||||||
|
|
||||||
### Feature `collections`
|
|
||||||
|
|
||||||
The `collections` feature enables use of `Vec` through a dependency on
|
|
||||||
the `collections` crate. This only works on nightly rustc.
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))]
|
#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))]
|
||||||
#![cfg_attr(all(feature = "collections", not(feature = "std")), feature(collections))]
|
|
||||||
|
|
||||||
//! A library that provides a way to logically own objects, whether or not
|
//! A library that provides a way to logically own objects, whether or not
|
||||||
//! heap allocation is available.
|
//! heap allocation is available.
|
||||||
|
@ -9,8 +8,6 @@
|
||||||
extern crate std;
|
extern crate std;
|
||||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
#[cfg(all(feature = "collections", not(feature = "std")))]
|
|
||||||
extern crate collections;
|
|
||||||
|
|
||||||
mod object;
|
mod object;
|
||||||
mod slice;
|
mod slice;
|
||||||
|
|
|
@ -7,8 +7,8 @@ use std::boxed::Box;
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
#[cfg(all(feature = "alloc", feature = "collections", not(feature = "std")))]
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
use collections::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
/// A managed object.
|
/// A managed object.
|
||||||
///
|
///
|
||||||
|
@ -61,7 +61,7 @@ impl<T: ?Sized + 'static> From<Box<T>> for Managed<'static, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", all(feature = "alloc", feature = "collections")))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: 'static> From<Vec<T>> for Managed<'static, [T]> {
|
impl<T: 'static> From<Vec<T>> for Managed<'static, [T]> {
|
||||||
fn from(value: Vec<T>) -> Self {
|
fn from(value: Vec<T>) -> Self {
|
||||||
Managed::Owned(value.into_boxed_slice())
|
Managed::Owned(value.into_boxed_slice())
|
||||||
|
|
18
src/slice.rs
18
src/slice.rs
|
@ -7,8 +7,8 @@ use std::boxed::Box;
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
#[cfg(all(feature = "collections", not(feature = "std")))]
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
use collections::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
/// A managed slice.
|
/// A managed slice.
|
||||||
///
|
///
|
||||||
|
@ -29,8 +29,8 @@ use collections::vec::Vec;
|
||||||
pub enum ManagedSlice<'a, T: 'a> {
|
pub enum ManagedSlice<'a, T: 'a> {
|
||||||
/// Borrowed variant.
|
/// Borrowed variant.
|
||||||
Borrowed(&'a mut [T]),
|
Borrowed(&'a mut [T]),
|
||||||
/// Owned variant, only available with the `std` or `collections` feature enabled.
|
/// Owned variant, only available with the `std` or `alloc` feature enabled.
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
Owned(Vec<T>)
|
Owned(Vec<T>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ impl<'a, T: 'a> fmt::Debug for ManagedSlice<'a, T>
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
&ManagedSlice::Borrowed(ref x) => write!(f, "Borrowed({:?})", x),
|
&ManagedSlice::Borrowed(ref x) => write!(f, "Borrowed({:?})", x),
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
&ManagedSlice::Owned(ref x) => write!(f, "Owned({:?})", x)
|
&ManagedSlice::Owned(ref x) => write!(f, "Owned({:?})", x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@ macro_rules! from_unboxed_slice {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", all(feature = "alloc", feature = "collections")))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
from_unboxed_slice!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
from_unboxed_slice!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
|
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: 'static> From<Vec<T>> for ManagedSlice<'static, T> {
|
impl<T: 'static> From<Vec<T>> for ManagedSlice<'static, T> {
|
||||||
fn from(value: Vec<T>) -> Self {
|
fn from(value: Vec<T>) -> Self {
|
||||||
ManagedSlice::Owned(value)
|
ManagedSlice::Owned(value)
|
||||||
|
@ -84,7 +84,7 @@ impl<'a, T: 'a> Deref for ManagedSlice<'a, T> {
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
match self {
|
match self {
|
||||||
&ManagedSlice::Borrowed(ref value) => value,
|
&ManagedSlice::Borrowed(ref value) => value,
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
&ManagedSlice::Owned(ref value) => value
|
&ManagedSlice::Owned(ref value) => value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ impl<'a, T: 'a> DerefMut for ManagedSlice<'a, T> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
match self {
|
match self {
|
||||||
&mut ManagedSlice::Borrowed(ref mut value) => value,
|
&mut ManagedSlice::Borrowed(ref mut value) => value,
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
&mut ManagedSlice::Owned(ref mut value) => value
|
&mut ManagedSlice::Owned(ref mut value) => value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue