Remove the `use_` prefix from feature names.

I haven't realized that a feature `log` with an optional crate
dependency `log` activates that dependency, and added the prefix
to avoid a "clash". This is unnecessary.
v0.7.x
whitequark 2017-03-05 05:43:12 +00:00
parent 76dd7e6dba
commit 2f11058e7d
5 changed files with 38 additions and 38 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "managed"
version = "0.2.1"
version = "0.3.0"
authors = ["whitequark <whitequark@whitequark.org>"]
description = "An interface for logically owning objects, whether or not heap allocation is available."
documentation = "https://docs.rs/managed/"
@ -11,7 +11,7 @@ keywords = ["ownership"]
license = "0BSD"
[features]
use_std = []
use_alloc = []
use_collections = []
default = ["use_std"]
std = []
alloc = []
collections = []
default = ["std"]

View File

@ -66,18 +66,18 @@ You probably want to disable default features and configure them one by one:
managed = { version = "...", default-features = false, features = ["..."] }
```
### Feature `use_std`
### Feature `std`
The `use_std` feature enables use of `Box` and `Vec` through a dependency on the `std` crate.
The `std` feature enables use of `Box` and `Vec` through a dependency on the `std` crate.
### Feature `use_alloc`
### Feature `alloc`
The `use_alloc` feature enables use of `Box` through a dependency on the `alloc` crate.
The `alloc` feature enables use of `Box` through a dependency on the `alloc` crate.
This only works on nightly rustc.
### Feature `use_collections`
### Feature `collections`
The `use_collections` feature enables use of `Vec` through a dependency on
The `collections` feature enables use of `Vec` through a dependency on
the `collections` crate. This only works on nightly rustc.
Usage

View File

@ -1,15 +1,15 @@
#![no_std]
#![cfg_attr(all(feature = "use_alloc", not(feature = "use_std")), feature(alloc))]
#![cfg_attr(all(feature = "use_collections", not(feature = "use_std")), feature(collections))]
#![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
//! heap allocation is available.
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
extern crate std;
#[cfg(all(feature = "use_alloc", not(feature = "use_std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc;
#[cfg(all(feature = "use_collections", not(feature = "use_std")))]
#[cfg(all(feature = "collections", not(feature = "std")))]
extern crate collections;
mod object;

View File

@ -1,13 +1,13 @@
use core::ops::{Deref, DerefMut};
use core::fmt;
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
use std::boxed::Box;
#[cfg(all(feature = "use_alloc", not(feature = "use_std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::boxed::Box;
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
use std::vec::Vec;
#[cfg(all(feature = "use_alloc", feature = "use_collections", not(feature = "use_std")))]
#[cfg(all(feature = "alloc", feature = "collections", not(feature = "std")))]
use collections::vec::Vec;
/// A managed object.
@ -31,8 +31,8 @@ use collections::vec::Vec;
pub enum Managed<'a, T: 'a + ?Sized> {
/// Borrowed variant.
Borrowed(&'a mut T),
/// Owned variant, only available with the `use_std` or `use_alloc` feature enabled.
#[cfg(any(feature = "use_std", feature = "use_alloc"))]
/// Owned variant, only available with the `std` or `alloc` feature enabled.
#[cfg(any(feature = "std", feature = "alloc"))]
Owned(Box<T>)
}
@ -41,7 +41,7 @@ impl<'a, T: 'a + ?Sized> fmt::Debug for Managed<'a, T>
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&Managed::Borrowed(ref x) => write!(f, "Borrowed({:?})", x),
#[cfg(any(feature = "use_std", feature = "use_alloc"))]
#[cfg(any(feature = "std", feature = "alloc"))]
&Managed::Owned(ref x) => write!(f, "Owned({:?})", x)
}
@ -54,14 +54,14 @@ impl<'a, T: 'a + ?Sized> From<&'a mut T> for Managed<'a, T> {
}
}
#[cfg(any(feature = "use_std", feature = "use_alloc"))]
#[cfg(any(feature = "std", feature = "alloc"))]
impl<T: ?Sized + 'static> From<Box<T>> for Managed<'static, T> {
fn from(value: Box<T>) -> Self {
Managed::Owned(value)
}
}
#[cfg(any(feature = "use_std", all(feature = "use_alloc", feature = "use_collections")))]
#[cfg(any(feature = "std", all(feature = "alloc", feature = "collections")))]
impl<T: 'static> From<Vec<T>> for Managed<'static, [T]> {
fn from(value: Vec<T>) -> Self {
Managed::Owned(value.into_boxed_slice())
@ -74,7 +74,7 @@ impl<'a, T: 'a + ?Sized> Deref for Managed<'a, T> {
fn deref(&self) -> &Self::Target {
match self {
&Managed::Borrowed(ref value) => value,
#[cfg(any(feature = "use_std", feature = "use_alloc"))]
#[cfg(any(feature = "std", feature = "alloc"))]
&Managed::Owned(ref value) => value
}
}
@ -84,7 +84,7 @@ impl<'a, T: 'a + ?Sized> DerefMut for Managed<'a, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
match self {
&mut Managed::Borrowed(ref mut value) => value,
#[cfg(any(feature = "use_std", feature = "use_alloc"))]
#[cfg(any(feature = "std", feature = "alloc"))]
&mut Managed::Owned(ref mut value) => value
}
}

View File

@ -1,13 +1,13 @@
use core::ops::{Deref, DerefMut};
use core::fmt;
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
use std::boxed::Box;
#[cfg(all(feature = "use_alloc", not(feature = "use_std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::boxed::Box;
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
use std::vec::Vec;
#[cfg(all(feature = "use_collections", not(feature = "use_std")))]
#[cfg(all(feature = "collections", not(feature = "std")))]
use collections::vec::Vec;
/// A managed slice.
@ -29,8 +29,8 @@ use collections::vec::Vec;
pub enum ManagedSlice<'a, T: 'a> {
/// Borrowed variant.
Borrowed(&'a mut [T]),
/// Owned variant, only available with the `use_std` or `use_collections` feature enabled.
#[cfg(any(feature = "use_std", feature = "use_collections"))]
/// Owned variant, only available with the `std` or `collections` feature enabled.
#[cfg(any(feature = "std", feature = "collections"))]
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 {
match self {
&ManagedSlice::Borrowed(ref x) => write!(f, "Borrowed({:?})", x),
#[cfg(any(feature = "use_std", feature = "use_collections"))]
#[cfg(any(feature = "std", feature = "collections"))]
&ManagedSlice::Owned(ref x) => write!(f, "Owned({:?})", x)
}
@ -67,11 +67,11 @@ macro_rules! from_unboxed_slice {
)
}
#[cfg(any(feature = "use_std", all(feature = "use_alloc", feature = "use_collections")))]
#[cfg(any(feature = "std", all(feature = "alloc", feature = "collections")))]
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);
#[cfg(any(feature = "use_std", feature = "use_collections"))]
#[cfg(any(feature = "std", feature = "collections"))]
impl<T: 'static> From<Vec<T>> for ManagedSlice<'static, T> {
fn from(value: Vec<T>) -> Self {
ManagedSlice::Owned(value)
@ -84,7 +84,7 @@ impl<'a, T: 'a> Deref for ManagedSlice<'a, T> {
fn deref(&self) -> &Self::Target {
match self {
&ManagedSlice::Borrowed(ref value) => value,
#[cfg(any(feature = "use_std", feature = "use_collections"))]
#[cfg(any(feature = "std", feature = "collections"))]
&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 {
match self {
&mut ManagedSlice::Borrowed(ref mut value) => value,
#[cfg(any(feature = "use_std", feature = "use_collections"))]
#[cfg(any(feature = "std", feature = "collections"))]
&mut ManagedSlice::Owned(ref mut value) => value
}
}