pub(crate) fn string_display_with(
        &self,
        s: &mut String,
        buf: &mut String,
        caller: impl ProtocolCaller,
    ) -> Result<fmt::Result, VmError> {
        use crate::FromValue as _;

        match self {
            Value::Format(format) => {
                format.spec.format(&format.value, s, buf, caller)?;
            }
            Value::Char(c) => {
                s.push(*c);
            }
            Value::String(string) => {
                s.push_str(&string.borrow_ref()?);
            }
            Value::StaticString(string) => {
                s.push_str(string.as_ref());
            }
            Value::Integer(integer) => {
                let mut buffer = itoa::Buffer::new();
                s.push_str(buffer.format(*integer));
            }
            Value::Float(float) => {
                let mut buffer = ryu::Buffer::new();
                s.push_str(buffer.format(*float));
            }
            Value::Bool(bool) => {
                return Ok(write!(s, "{}", bool));
            }
            Value::Byte(byte) => {
                return Ok(write!(s, "{:#04X}", byte));
            }
            value => {
                let b = Shared::new(std::mem::take(s));

                let result = caller.call_protocol_fn(
                    Protocol::STRING_DISPLAY,
                    value.clone(),
                    (Value::from(b.clone()),),
                )?;

                let result = fmt::Result::from_value(result)?;
                drop(std::mem::replace(s, b.take()?));
                return Ok(result);
            }
        }

        Ok(Ok(()))
    }
/// Internal impl of string_display with a customizable caller.
Internal impl of string_display with a customizable caller.
Internal impl of string_display with a customizable caller .
pub(crate) fn string_display_with(
        &self,
        s: &mut String,
        buf: &mut String,
        caller: impl ProtocolCaller,
    ) -> Result<fmt::Result, VmError> {
        use crate::FromValue as _;
        match self {
            Value::Format(format) => {
                format.spec.format(&format.value, s, buf, caller)?;
            }
            Value::Char(c) => {
                s.push(*c);
            }
            Value::String(string) => {
                s.push_str(&string.borrow_ref()?);
            }
            Value::StaticString(string) => {
                s.push_str(string.as_ref());
            }
            Value::Integer(integer) => {
                let mut buffer = itoa::Buffer::new();
                s.push_str(buffer.format(*integer));
            }
            Value::Float(float) => {
                let mut buffer = ryu::Buffer::new();
                s.push_str(buffer.format(*float));
            }
            Value::Bool(bool) => {
                return Ok(write!(s, "{}", bool));
            }
            Value::Byte(byte) => {
                return Ok(write!(s, "{:#04X}", byte));
            }
            value => {
                let b = Shared::new(std::mem::take(s));
                let result = caller.call_protocol_fn(
                    Protocol::STRING_DISPLAY,
                    value.clone(),
                    (Value::from(b.clone()),),
                )?;
                let result = fmt::Result::from_value(result)?;
                drop(std::mem::replace(s, b.take()?));
                return Ok(result);
            }
        }
        Ok(Ok(()))
    }
pub ( crate ) fn string_display_with ( & self , s : & mut String , buf : & mut String , caller : impl ProtocolCaller , ) -> Result < fmt :: Result , VmError > { use crate :: FromValue as _ ; match self { Value :: Format ( format ) => { format . spec . format ( & format . value , s , buf , caller ) ? ; } Value :: Char ( c ) => { s . push ( * c ) ; } Value :: String ( string ) => { s . push_str ( & string . borrow_ref ( ) ? ) ; } Value :: StaticString ( string ) => { s . push_str ( string . as_ref ( ) ) ; } Value :: Integer ( integer ) => { let mut buffer = itoa :: Buffer :: new ( ) ; s . push_str ( buffer . format ( * integer ) ) ; } Value :: Float ( float ) => { let mut buffer = ryu :: Buffer :: new ( ) ; s . push_str ( buffer . format ( * float ) ) ; } Value :: Bool ( bool ) => { return Ok ( write ! ( s " " bool ) ) ; } Value :: Byte ( byte ) => { return Ok ( write ! ( s " " byte ) ) ; } value => { let b = Shared :: new ( std :: mem :: take ( s ) ) ; let result = caller . call_protocol_fn ( Protocol :: STRING_DISPLAY , value . clone ( ) , ( Value :: from ( b . clone ( ) ) , ) , ) ? ; let result = fmt :: Result :: from_value ( result ) ? ; drop ( std :: mem :: replace ( s , b . take ( ) ? ) ) ; return Ok ( result ) ; } } Ok ( Ok ( ( ) ) ) }
Internal impl of string_display with a customizable caller.
Internal impl of string_display with a customizable caller .
&self
s
&mut String
buf
&mut String
caller
impl ProtocolCaller
&self
s
&mut String
buf
&mut String
caller
impl ProtocolCaller