Replace NonZeroU32 and NonZeroUsize with a generic NonZero

The API is identical to core::nonzero::NonZero
This commit is contained in:
Simon Sapin 2017-10-14 12:27:26 +02:00
parent 4ee1b26b6c
commit 9e4865b6c8
7 changed files with 115 additions and 67 deletions

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use euclid::Size2D;
use nonzero::NonZeroU32;
use nonzero::NonZero;
use offscreen_gl_context::{GLContextAttributes, GLLimits};
use std::fmt;
use webrender_api;
@ -242,13 +242,13 @@ pub enum WebGLCommand {
macro_rules! define_resource_id_struct {
($name:ident) => {
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub struct $name(NonZeroU32);
pub struct $name(NonZero<u32>);
impl $name {
#[allow(unsafe_code)]
#[inline]
pub unsafe fn new(id: u32) -> Self {
$name(NonZeroU32::new_unchecked(id))
$name(NonZero::new_unchecked(id))
}
#[inline]