@@ -15,6 +15,7 @@ matrix:
|
||||
- NODROP_FEATURES='use_needs_drop'
|
||||
- rust: nightly
|
||||
env:
|
||||
- FEATURES='use_union'
|
||||
- NODROP_FEATURES='use_union'
|
||||
branches:
|
||||
only:
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "arrayvec"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
authors = ["bluss"]
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
@@ -15,10 +15,11 @@ version = "0.2.12"
|
||||
default-features = false
|
||||
|
||||
[dependencies.nodrop]
|
||||
version = "0.1.6"
|
||||
version = "0.1.8"
|
||||
path = "nodrop"
|
||||
default-features = false
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["odds/std", "nodrop/std"]
|
||||
use_union = ["nodrop/use_union"]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
DOCCRATES = arrayvec nodrop odds
|
||||
DOCCRATES = arrayvec nodrop nodrop_union odds
|
||||
|
||||
# deps to delete the generated docs
|
||||
RMDOCS =
|
||||
|
||||
FEATURES = odds/unstable
|
||||
FEATURES = "odds/unstable nodrop/use_union"
|
||||
|
||||
VERSIONS = $(patsubst %,target/VERS/%,$(DOCCRATES))
|
||||
|
||||
|
||||
+16
@@ -22,6 +22,11 @@ __ http://bluss.github.io/arrayvec
|
||||
Recent Changes (arrayvec)
|
||||
-------------------------
|
||||
|
||||
- 0.3.17
|
||||
|
||||
- Added crate feature ``use_union`` which forwards to the nodrop crate feature
|
||||
- Added methods ``.is_full()`` to ``ArrayVec`` and ``ArrayString``.
|
||||
|
||||
- 0.3.16
|
||||
|
||||
- Added method ``.retain()`` to ``ArrayVec``.
|
||||
@@ -91,6 +96,17 @@ Recent Changes (nodrop)
|
||||
optimization, which skips overwriting if the inner value does not need
|
||||
drop.
|
||||
|
||||
Recent Changes (nodrop-union)
|
||||
-----------------------
|
||||
|
||||
- 0.1.9
|
||||
|
||||
- Add ``Copy, Clone`` implementations
|
||||
|
||||
- 0.1.8
|
||||
|
||||
- Initial release
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
[package]
|
||||
name = "nodrop-union"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
authors = ["bluss"]
|
||||
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
description = "A wrapper type to inhibit drop (destructor). Implementation crate for nodrop, the untagged unions implementation (which is unstable / requires nightly) as of this writing."
|
||||
documentation = "http://bluss.github.io/arrayvec/doc/nodrop"
|
||||
documentation = "http://bluss.github.io/arrayvec/doc/nodrop_union"
|
||||
repository = "https://github.com/bluss/arrayvec"
|
||||
|
||||
keywords = ["container", "drop", "no_std"]
|
||||
|
||||
+30
-14
@@ -1,19 +1,21 @@
|
||||
//!
|
||||
//! The **nodrop** crate has the following cargo feature flags:
|
||||
//! **nodrop-union** is the untagged unions (requires Rust nightly channel and
|
||||
//! unstable as of this writing) implementation for the **nodrop** crate.
|
||||
//!
|
||||
//! - `std`
|
||||
//! - Optional, enabled by default
|
||||
//! - Requires Rust 1.6 *to disable*
|
||||
//! - Use libstd
|
||||
//! - `use_needs_drop`
|
||||
//! - Optional
|
||||
//! - Requires nightly channel.
|
||||
//! - Use `needs_drop` to skip overwriting if not necessary
|
||||
//! - `use_union`
|
||||
//! - Optional
|
||||
//! - Requires nightly channel
|
||||
//! - Using untagged union, finally we have an implementation of `NoDrop` without hacks,
|
||||
//! for example the fact that `NoDrop<T>` never has a destructor anymore.
|
||||
//! It is intended you use this through the **nodrop** crate with the `use_union`
|
||||
//! crate feature enabled.
|
||||
//!
|
||||
//! This is the future implementation of nodrop, once it is stable.
|
||||
//!
|
||||
//! This implementation is a lot better:
|
||||
//!
|
||||
//! - Does not have a destructor at all
|
||||
//! - Can be Copy if T is Copy
|
||||
//! - No space overhead / no runtime flag
|
||||
//!
|
||||
//! This means that this implementation has extensions that the
|
||||
//! stable nodrop does not yet have, which is something to be aware of if
|
||||
//! you are switching.
|
||||
//!
|
||||
|
||||
#![feature(untagged_unions)]
|
||||
@@ -25,10 +27,24 @@ extern crate core as std;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
#[allow(unions_with_drop_fields)]
|
||||
#[derive(Copy)]
|
||||
union UnionFlag<T> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
impl<T: Clone> Clone for UnionFlag<T> {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
UnionFlag { value: self.value.clone() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A type holding **T** that will not call its destructor on drop
|
||||
///
|
||||
/// The untagged unions implementation of `NoDrop<T>` is Copy where T: Copy,
|
||||
/// which was not possible in the stable implementation.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct NoDrop<T>(UnionFlag<T>);
|
||||
|
||||
impl<T> NoDrop<T> {
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
//! - Optional, enabled by default
|
||||
//! - Requires Rust 1.6 *to disable*
|
||||
//! - Use libstd
|
||||
//!
|
||||
//! - `use_union`
|
||||
//! - Optional
|
||||
//! - Requires Rust nightly channel
|
||||
//! - Use the unstable feature untagged unions for the internal implementation,
|
||||
//! which has reduced space overhead
|
||||
#![cfg_attr(not(feature="std"), no_std)]
|
||||
extern crate odds;
|
||||
extern crate nodrop;
|
||||
|
||||
Reference in New Issue
Block a user