std: add Primitive.is_signed
This commit is contained in:
parent
50fde8c024
commit
41f9deb2ee
5 changed files with 13 additions and 0 deletions
|
@ -590,6 +590,9 @@ impl Primitive for f32 {
|
|||
|
||||
#[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 @@ impl Primitive for f64 {
|
|||
|
||||
#[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 @@ impl Primitive for $T {
|
|||
|
||||
#[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 @@ impl Primitive for $T {
|
|||
|
||||
#[inline]
|
||||
fn bytes(_: Option<$T>) -> uint { bits / 8 }
|
||||
|
||||
#[inline]
|
||||
fn is_signed(_: Option<$T>) -> bool { false }
|
||||
}
|
||||
|
||||
impl BitCount for $T {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue