Struct dactyl::NiceU8 [−][src]
pub struct NiceU8 { /* fields omitted */ }
Expand description
NiceU8
provides a quick way to convert a u8
into a formatted byte
string for e.g. printing.
That’s it!
Examples
use dactyl::NiceU8;
assert_eq!(
NiceU8::from(231).as_str(),
"231"
);
Implementations
Casting.
This section provides methods for converting instances into other types.
Note: this struct can also be dereferenced to &[u8]
.
Double Digit Bytes.
This method will return return a byte slice that is at least two bytes long, left padding the value with a zero if its natural length is shorter. (In other words, this has no effect if the value is >= 10.)
Examples
assert_eq!(dactyl::NiceU8::from(3).as_bytes2(), b"03");
assert_eq!(dactyl::NiceU8::from(50).as_bytes2(), b"50");
assert_eq!(dactyl::NiceU8::from(113).as_bytes2(), b"113");
Triple Digit Bytes.
This method will return return a byte slice that is at least three bytes long, left padding the value with a zero if its natural length is shorter. (In other words, this has no effect if the value is >= 100.)
Examples
assert_eq!(dactyl::NiceU8::from(3).as_bytes3(), b"003");
assert_eq!(dactyl::NiceU8::from(50).as_bytes3(), b"050");
assert_eq!(dactyl::NiceU8::from(113).as_bytes3(), b"113");
Double Digit Str.
This method will return return a string slice that is at least two chars long, left padding the value with a zero if its natural length is shorter. (In other words, this has no effect if the value is >= 10.)
Examples
assert_eq!(dactyl::NiceU8::from(3).as_str2(), "03");
assert_eq!(dactyl::NiceU8::from(50).as_str2(), "50");
assert_eq!(dactyl::NiceU8::from(113).as_str2(), "113");
Triple Digit Str.
This method will return return a string slice that is at least three chars long, left padding the value with zeroes if its natural length is shorter. (In other words, this has no effect if the value is >= 100.)
Examples
assert_eq!(dactyl::NiceU8::from(3).as_str3(), "003");
assert_eq!(dactyl::NiceU8::from(50).as_str3(), "050");
assert_eq!(dactyl::NiceU8::from(113).as_str3(), "113");
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for NiceU8
impl UnwindSafe for NiceU8
Blanket Implementations
Mutably borrows from an owned value. Read more