mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 14:52:56 +03:00
std: add Primitive.is_signed
This commit is contained in:
@@ -590,6 +590,9 @@ fn bits(_: Option<f32>) -> uint { 32 }
|
||||
|
||||
#[inline]
|
||||
fn bytes(_: Option<f32>) -> uint { Primitive::bits(Some(0f32)) / 8 }
|
||||
|
||||
#[inline]
|
||||
fn is_signed(_: Option<f32>) -> bool { true }
|
||||
}
|
||||
|
||||
impl Float for f32 {
|
||||
|
||||
@@ -638,6 +638,9 @@ fn bits(_: Option<f64>) -> uint { 64 }
|
||||
|
||||
#[inline]
|
||||
fn bytes(_: Option<f64>) -> uint { Primitive::bits(Some(0f64)) / 8 }
|
||||
|
||||
#[inline]
|
||||
fn is_signed(_: Option<f64>) -> bool { true }
|
||||
}
|
||||
|
||||
impl Float for f64 {
|
||||
|
||||
@@ -380,6 +380,9 @@ fn bits(_: Option<$T>) -> uint { bits }
|
||||
|
||||
#[inline]
|
||||
fn bytes(_: Option<$T>) -> uint { bits / 8 }
|
||||
|
||||
#[inline]
|
||||
fn is_signed(_: Option<$T>) -> bool { true }
|
||||
}
|
||||
|
||||
// String conversion functions and impl str -> num
|
||||
|
||||
@@ -286,6 +286,7 @@ pub trait Primitive: Clone
|
||||
// FIXME (#8888): Removing `unused_self` requires #8888 to be fixed.
|
||||
fn bits(unused_self: Option<Self>) -> uint;
|
||||
fn bytes(unused_self: Option<Self>) -> uint;
|
||||
fn is_signed(unused_self: Option<Self>) -> bool;
|
||||
}
|
||||
|
||||
/// A collection of traits relevant to primitive signed and unsigned integers
|
||||
|
||||
@@ -306,6 +306,9 @@ fn bits(_: Option<$T>) -> uint { bits }
|
||||
|
||||
#[inline]
|
||||
fn bytes(_: Option<$T>) -> uint { bits / 8 }
|
||||
|
||||
#[inline]
|
||||
fn is_signed(_: Option<$T>) -> bool { false }
|
||||
}
|
||||
|
||||
impl BitCount for $T {
|
||||
|
||||
Reference in New Issue
Block a user