Permalink
Browse files

Use wrappers in the nonzero crate so users don’t need unstable features

  • Loading branch information...
SimonSapin committed Oct 12, 2017
1 parent 9dbcea0 commit ac60a803bbccaa34d2c98a69e6761d55e9932fac
@@ -9,9 +9,6 @@ publish = false
name = "canvas_traits"
path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies]
cssparser = "0.22.0"
euclid = "0.15"
@@ -5,8 +5,6 @@
#![crate_name = "canvas_traits"]
#![crate_type = "rlib"]
#![cfg_attr(feature = "unstable", feature(nonzero))]
#![deny(unsafe_code)]
extern crate cssparser;
@@ -9,9 +9,6 @@ publish = false
name = "compositing"
path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies]
euclid = "0.15"
gfx_traits = {path = "../gfx_traits"}
@@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)]
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate euclid;
extern crate gfx_traits;
@@ -9,9 +9,6 @@ publish = false
name = "constellation"
path = "lib.rs"
[features]
unstable = ["servo_remutex/unstable"]
[dependencies]
backtrace = "0.3"
bluetooth_traits = { path = "../bluetooth_traits" }
View
@@ -5,7 +5,6 @@
#![deny(unsafe_code)]
#![feature(box_patterns)]
#![feature(conservative_impl_trait)]
#![feature(nonzero)]
#![feature(raw)]
extern crate app_units;
@@ -6,7 +6,6 @@
//! painted.
#![feature(mpsc_select)]
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate app_units;
extern crate atomic_refcell;
View
@@ -2,9 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![cfg_attr(feature = "unstable", feature(nonzero))]
#![cfg_attr(feature = "unstable", feature(const_fn))]
#![cfg_attr(feature = "unstable", feature(const_nonzero_new))]
#![deny(unsafe_code)]
#[macro_use]
View
@@ -6,8 +6,9 @@
//! or some stable types with an equivalent API (but no memory layout optimization).
#![cfg_attr(feature = "unstable", feature(nonzero))]
#![cfg_attr(feature = "unstable", feature(const_fn))]
#![cfg_attr(feature = "unstable", feature(const_nonzero_new))]
#[cfg(not(feature = "unstable"))]
#[macro_use]
extern crate serde;
@@ -18,8 +19,23 @@ mod imp {
extern crate core;
use self::core::nonzero::NonZero;
pub type NonZeroU32 = NonZero<u32>;
pub type NonZeroUsize = NonZero<usize>;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct NonZeroU32(NonZero<u32>);
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct NonZeroUsize(NonZero<usize>);
impl NonZeroU32 {
#[inline] pub const unsafe fn new_unchecked(x: u32) -> Self { NonZeroU32(NonZero::new_unchecked(x)) }
#[inline] pub fn new(x: u32) -> Option<Self> { NonZero::new(x).map(NonZeroU32) }
#[inline] pub fn get(self) -> u32 { self.0.get() }
}
impl NonZeroUsize {
#[inline] pub const unsafe fn new_unchecked(x: usize) -> Self { NonZeroUsize(NonZero::new_unchecked(x)) }
#[inline] pub fn new(x: usize) -> Option<Self> { NonZero::new(x).map(NonZeroUsize) }
#[inline] pub fn get(self) -> usize { self.0.get() }
}
}
#[cfg(not(feature = "unstable"))]
@@ -9,9 +9,6 @@ publish = false
name = "servo_remutex"
path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies]
lazy_static = "0.2"
log = "0.3.5"
@@ -10,8 +10,6 @@
//! It provides the same interface as https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/remutex.rs
//! so if those types are ever exported, we should be able to replace this implemtation.
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate nonzero;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
@@ -9,9 +9,6 @@ publish = false
name = "script_layout_interface"
path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies]
app_units = "0.5"
atomic_refcell = "0.1"
@@ -7,7 +7,6 @@
//! to depend on script.
#![deny(unsafe_code)]
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate app_units;
extern crate atomic_refcell;
@@ -20,14 +20,9 @@ googlevr = ["webvr/googlevr"]
oculusvr = ["webvr/oculusvr"]
unstable = [
"euclid/unstable",
"layout_thread/unstable",
"msg/unstable",
"canvas_traits/unstable",
"compositing/unstable",
"constellation/unstable",
"gfx/unstable",
"profile/unstable",
"script_layout_interface/unstable",
]
[dependencies]

0 comments on commit ac60a80

Please sign in to comment.