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

        let result = match self {
            Value::Unit => {
                write!(s, "()")
            }
            Value::Bool(value) => {
                write!(s, "{:?}", value)
            }
            Value::Byte(value) => {
                write!(s, "{:?}", value)
            }
            Value::Char(value) => {
                write!(s, "{:?}", value)
            }
            Value::Integer(value) => {
                write!(s, "{:?}", value)
            }
            Value::Float(value) => {
                write!(s, "{:?}", value)
            }
            Value::Type(value) => {
                write!(s, "Type({})", value)
            }
            Value::StaticString(value) => {
                write!(s, "{:?}", value)
            }
            Value::String(value) => {
                write!(s, "{:?}", value)
            }
            Value::Bytes(value) => {
                write!(s, "{:?}", value)
            }
            Value::Vec(value) => {
                write!(s, "{:?}", value)
            }
            Value::Tuple(value) => {
                write!(s, "{:?}", value)
            }
            Value::Object(value) => {
                write!(s, "{:?}", value)
            }
            Value::Range(value) => {
                write!(s, "{:?}", value)
            }
            Value::Future(value) => {
                write!(s, "{:?}", value)
            }
            Value::Stream(value) => {
                write!(s, "{:?}", value)
            }
            Value::Generator(value) => {
                write!(s, "{:?}", value)
            }
            Value::GeneratorState(value) => {
                write!(s, "{:?}", value)
            }
            Value::Option(value) => {
                write!(s, "{:?}", value)
            }
            Value::Result(value) => {
                write!(s, "{:?}", value)
            }
            Value::UnitStruct(value) => {
                write!(s, "{:?}", value)
            }
            Value::TupleStruct(value) => {
                write!(s, "{:?}", value)
            }
            Value::Struct(value) => {
                write!(s, "{:?}", value)
            }
            Value::Variant(value) => {
                write!(s, "{:?}", value)
            }
            Value::Function(value) => {
                write!(s, "{:?}", value)
            }
            Value::Format(value) => {
                write!(s, "{:?}", value)
            }
            Value::Iterator(value) => {
                write!(s, "{:?}", value)
            }
            value => {
                let b = Shared::new(std::mem::take(s));

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

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

        Ok(result)
    }
/// Internal impl of string_debug with a customizable caller.
Internal impl of string_debug with a customizable caller.
Internal impl of string_debug with a customizable caller .
pub(crate) fn string_debug_with(
        &self,
        s: &mut String,
        caller: impl ProtocolCaller,
    ) -> Result<fmt::Result, VmError> {
        use crate::FromValue as _;
        use std::fmt::Write as _;
        let result = match self {
            Value::Unit => {
                write!(s, "()")
            }
            Value::Bool(value) => {
                write!(s, "{:?}", value)
            }
            Value::Byte(value) => {
                write!(s, "{:?}", value)
            }
            Value::Char(value) => {
                write!(s, "{:?}", value)
            }
            Value::Integer(value) => {
                write!(s, "{:?}", value)
            }
            Value::Float(value) => {
                write!(s, "{:?}", value)
            }
            Value::Type(value) => {
                write!(s, "Type({})", value)
            }
            Value::StaticString(value) => {
                write!(s, "{:?}", value)
            }
            Value::String(value) => {
                write!(s, "{:?}", value)
            }
            Value::Bytes(value) => {
                write!(s, "{:?}", value)
            }
            Value::Vec(value) => {
                write!(s, "{:?}", value)
            }
            Value::Tuple(value) => {
                write!(s, "{:?}", value)
            }
            Value::Object(value) => {
                write!(s, "{:?}", value)
            }
            Value::Range(value) => {
                write!(s, "{:?}", value)
            }
            Value::Future(value) => {
                write!(s, "{:?}", value)
            }
            Value::Stream(value) => {
                write!(s, "{:?}", value)
            }
            Value::Generator(value) => {
                write!(s, "{:?}", value)
            }
            Value::GeneratorState(value) => {
                write!(s, "{:?}", value)
            }
            Value::Option(value) => {
                write!(s, "{:?}", value)
            }
            Value::Result(value) => {
                write!(s, "{:?}", value)
            }
            Value::UnitStruct(value) => {
                write!(s, "{:?}", value)
            }
            Value::TupleStruct(value) => {
                write!(s, "{:?}", value)
            }
            Value::Struct(value) => {
                write!(s, "{:?}", value)
            }
            Value::Variant(value) => {
                write!(s, "{:?}", value)
            }
            Value::Function(value) => {
                write!(s, "{:?}", value)
            }
            Value::Format(value) => {
                write!(s, "{:?}", value)
            }
            Value::Iterator(value) => {
                write!(s, "{:?}", value)
            }
            value => {
                let b = Shared::new(std::mem::take(s));
                let result = caller.call_protocol_fn(
                    Protocol::STRING_DEBUG,
                    value.clone(),
                    (Value::from(b.clone()),),
                )?;
                let result = fmt::Result::from_value(result)?;
                drop(std::mem::replace(s, b.take()?));
                return Ok(result);
            }
        };
        Ok(result)
    }
pub ( crate ) fn string_debug_with ( & self , s : & mut String , caller : impl ProtocolCaller , ) -> Result < fmt :: Result , VmError > { use crate :: FromValue as _ ; use std :: fmt :: Write as _ ; let result = match self { Value :: Unit => { write ! ( s " " ) } Value :: Bool ( value ) => { write ! ( s " " value ) } Value :: Byte ( value ) => { write ! ( s " " value ) } Value :: Char ( value ) => { write ! ( s " " value ) } Value :: Integer ( value ) => { write ! ( s " " value ) } Value :: Float ( value ) => { write ! ( s " " value ) } Value :: Type ( value ) => { write ! ( s " " value ) } Value :: StaticString ( value ) => { write ! ( s " " value ) } Value :: String ( value ) => { write ! ( s " " value ) } Value :: Bytes ( value ) => { write ! ( s " " value ) } Value :: Vec ( value ) => { write ! ( s " " value ) } Value :: Tuple ( value ) => { write ! ( s " " value ) } Value :: Object ( value ) => { write ! ( s " " value ) } Value :: Range ( value ) => { write ! ( s " " value ) } Value :: Future ( value ) => { write ! ( s " " value ) } Value :: Stream ( value ) => { write ! ( s " " value ) } Value :: Generator ( value ) => { write ! ( s " " value ) } Value :: GeneratorState ( value ) => { write ! ( s " " value ) } Value :: Option ( value ) => { write ! ( s " " value ) } Value :: Result ( value ) => { write ! ( s " " value ) } Value :: UnitStruct ( value ) => { write ! ( s " " value ) } Value :: TupleStruct ( value ) => { write ! ( s " " value ) } Value :: Struct ( value ) => { write ! ( s " " value ) } Value :: Variant ( value ) => { write ! ( s " " value ) } Value :: Function ( value ) => { write ! ( s " " value ) } Value :: Format ( value ) => { write ! ( s " " value ) } Value :: Iterator ( value ) => { write ! ( s " " value ) } value => { let b = Shared :: new ( std :: mem :: take ( s ) ) ; let result = caller . call_protocol_fn ( Protocol :: STRING_DEBUG , value . clone ( ) , ( Value :: from ( b . clone ( ) ) , ) , ) ? ; let result = fmt :: Result :: from_value ( result ) ? ; drop ( std :: mem :: replace ( s , b . take ( ) ? ) ) ; return Ok ( result ) ; } } ; Ok ( result ) }
Internal impl of string_debug with a customizable caller.
Internal impl of string_debug with a customizable caller .
&self
s
&mut String
caller
impl ProtocolCaller
&self
s
&mut String
caller
impl ProtocolCaller