mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use new std::num::NonZero* types instead of deprecated core::nonzero::NonZero
This commit is contained in:
parent
3d6614e314
commit
52dceb3d5f
5 changed files with 114 additions and 143 deletions
|
@ -5,7 +5,7 @@
|
|||
//! The high-level interface from script to constellation. Using this abstract interface helps
|
||||
//! reduce coupling between these two components.
|
||||
|
||||
use nonzero::NonZero;
|
||||
use nonzero::NonZeroU32;
|
||||
use std::cell::Cell;
|
||||
use std::fmt;
|
||||
use webrender_api;
|
||||
|
@ -195,9 +195,9 @@ impl PipelineNamespace {
|
|||
});
|
||||
}
|
||||
|
||||
fn next_index(&mut self) -> NonZero<u32> {
|
||||
fn next_index(&mut self) -> NonZeroU32 {
|
||||
self.index += 1;
|
||||
NonZero::new(self.index).expect("pipeline id index wrapped!")
|
||||
NonZeroU32::new(self.index).expect("pipeline id index wrapped!")
|
||||
}
|
||||
|
||||
fn next_pipeline_id(&mut self) -> PipelineId {
|
||||
|
@ -221,7 +221,7 @@ thread_local!(pub static PIPELINE_NAMESPACE: Cell<Option<PipelineNamespace>> = C
|
|||
pub struct PipelineNamespaceId(pub u32);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct PipelineIndex(pub NonZero<u32>);
|
||||
pub struct PipelineIndex(pub NonZeroU32);
|
||||
malloc_size_of_is_0!(PipelineIndex);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
|
@ -252,7 +252,7 @@ impl PipelineId {
|
|||
unsafe {
|
||||
PipelineId {
|
||||
namespace_id: PipelineNamespaceId(namespace_id),
|
||||
index: PipelineIndex(NonZero::new_unchecked(index)),
|
||||
index: PipelineIndex(NonZeroU32::new_unchecked(index)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ impl fmt::Display for PipelineId {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct BrowsingContextIndex(pub NonZero<u32>);
|
||||
pub struct BrowsingContextIndex(pub NonZeroU32);
|
||||
malloc_size_of_is_0!(BrowsingContextIndex);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
|
@ -355,13 +355,13 @@ impl PartialEq<BrowsingContextId> for TopLevelBrowsingContextId {
|
|||
pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234);
|
||||
#[allow(unsafe_code)]
|
||||
#[cfg(feature = "unstable")]
|
||||
pub const TEST_PIPELINE_INDEX: PipelineIndex = unsafe { PipelineIndex(NonZero::new_unchecked(5678)) };
|
||||
pub const TEST_PIPELINE_INDEX: PipelineIndex = unsafe { PipelineIndex(NonZeroU32::new_unchecked(5678)) };
|
||||
#[cfg(feature = "unstable")]
|
||||
pub const TEST_PIPELINE_ID: PipelineId = PipelineId { namespace_id: TEST_NAMESPACE, index: TEST_PIPELINE_INDEX };
|
||||
#[allow(unsafe_code)]
|
||||
#[cfg(feature = "unstable")]
|
||||
pub const TEST_BROWSING_CONTEXT_INDEX: BrowsingContextIndex =
|
||||
unsafe { BrowsingContextIndex(NonZero::new_unchecked(8765)) };
|
||||
unsafe { BrowsingContextIndex(NonZeroU32::new_unchecked(8765)) };
|
||||
#[cfg(feature = "unstable")]
|
||||
pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId =
|
||||
BrowsingContextId { namespace_id: TEST_NAMESPACE, index: TEST_BROWSING_CONTEXT_INDEX };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue