Trait lexical_core::ToLexical

source ·
pub trait ToLexical: FormattedSize + Number {
    // Required methods
    unsafe fn to_lexical_unchecked<'a>(
        self,
        bytes: &'a mut [u8],
    ) -> &'a mut [u8];
    fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8];
}
Expand description

Trait for numerical types that can be serialized to bytes.

To determine the number of bytes required to serialize a value to string, check the associated constants from a required trait:

Required Methods§

source

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

Serializer for a number-to-string conversion.

Returns a subslice of the input buffer containing the written bytes, starting from the same address in memory as the input slice.

  • value - Number to serialize.
  • bytes - Buffer to write number to.
§Safety

Safe as long as the caller has provided a buffer of at least FORMATTED_SIZE_DECIMAL elements. If a smaller buffer is provided, a buffer overflow is very likely.

source

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

Serializer for a number-to-string conversion.

Returns a subslice of the input buffer containing the written bytes, starting from the same address in memory as the input slice.

  • value - Number to serialize.
  • bytes - Buffer to write number to.
§Panics

Panics if the buffer is not of sufficient size. The caller must provide a slice of sufficient size. In order to ensure the function will not panic, ensure the buffer has at least FORMATTED_SIZE_DECIMAL elements.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ToLexical for f32

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for f64

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for i8

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for i16

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for i32

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for i64

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for i128

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for isize

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for u8

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for u16

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for u32

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for u64

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for u128

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

impl ToLexical for usize

source§

unsafe fn to_lexical_unchecked<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

source§

fn to_lexical<'a>(self, bytes: &'a mut [u8]) -> &'a mut [u8]

Implementors§