pubtraitBinarypubfnfmt(&self, f:&mutFormatter<'_>)->Result<(),Error>;

b formateo.

los Binary el rasgo debe formatear su salida como un número en binario.

Para enteros primitivos con signo (i8 para i128, y isize), los valores negativos se formatean como la representación del complemento a dos.

La bandera alternativa, #, agrega un 0b delante de la salida.

Para obtener más información sobre formateadores, consulte la documentación a nivel de módulo.

Ejemplos de

Uso básico con i32:

let x =42;// 42 is '101010' in binaryassert_eq!(format!(":b", x),"101010");assert_eq!(format!(":#b", x),"0b101010");assert_eq!(format!(":b",-16),"11111111111111111111111111110000");

Implementar Binary en un tipo:

usestd::fmt;structLength(i32);implfmt::BinaryforLengthfnfmt(&self, f:&mutfmt::Formatter<'_>)->fmt::Resultlet val =self.0;fmt::Binary::fmt(&val, f)// delegate to i32's implementationlet l =Length(107);assert_eq!(format!("l as binary is: :b", l),"l as binary is: 1101011");assert_eq!(format!("l as binary is: :#032b", l),"l as binary is: 0b000000000000000000000001101011");

Métodos requeridos

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formatea el valor usando el formateador dado.

Cargando contenido …

Implementadores

impl Binary for i8[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for i16[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for i32[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for i64[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for i128[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for isize[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for u8[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for u16[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for u32[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for u64[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for u128[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for usize[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroI8[src]1.34.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroI16[src]1.34.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroI32[src]1.34.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroI64[src]1.34.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroI128[src]1.34.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroIsize[src]1.34.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroU8[src]1.28.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroU16[src]1.28.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroU32[src]1.28.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroU64[src]1.28.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroU128[src]1.28.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for NonZeroUsize[src]1.28.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl<'_, T> Binary for &'_ T where
    T: Binary + ?Sized
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl<'_, T> Binary for &'_ mut T where
    T: Binary + ?Sized
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

impl Binary for Wrapping where
    T: Binary
[src]1.11.0

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Cargando contenido …