/// Converts any TOML value to valid Rust types.
Converts any TOML value to valid Rust types.
Converts any TOML value to valid Rust types .
fn toml_to_ts(input: Value) -> TokenStream2 {
    match input {
        Value::String(s) => Lit::new(Literal::string(&s)).to_token_stream().into(),
        Value::Integer(i) => Lit::new(Literal::i64_suffixed(i)).to_token_stream().into(),
        Value::Float(f) => Lit::new(Literal::f64_suffixed(f)).to_token_stream().into(),
        Value::Datetime(d) => Lit::new(Literal::string(&d.to_string()))
            .to_token_stream()
            .into(),
        Value::Boolean(b) => Lit::Bool(LitBool::new(b, Span2::call_site()))
            .to_token_stream()
            .into(),
        Value::Array(a) => {
            let mut ts = TokenStream2::new();
            for value in a {
                let v = toml_to_ts(value);
                ts.extend(quote! (#v,));
            }
            quote! ((#ts))
        }
        Value::Table(t) => {
            let mut ts = TokenStream2::new();
            for (key, value) in t {
                let v = toml_to_ts(value);
                ts.extend(quote! ((#key, #v)));
            }
            quote! ((#ts))
        }
    }
}
fn toml_to_ts ( input : Value ) -> TokenStream2 { match input { Value :: String ( s ) => Lit :: new ( Literal :: string ( & s ) ) . to_token_stream ( ) . into ( ) , Value :: Integer ( i ) => Lit :: new ( Literal :: i64_suffixed ( i ) ) . to_token_stream ( ) . into ( ) , Value :: Float ( f ) => Lit :: new ( Literal :: f64_suffixed ( f ) ) . to_token_stream ( ) . into ( ) , Value :: Datetime ( d ) => Lit :: new ( Literal :: string ( & d . to_string ( ) ) ) . to_token_stream ( ) . into ( ) , Value :: Boolean ( b ) => Lit :: Bool ( LitBool :: new ( b , Span2 :: call_site ( ) ) ) . to_token_stream ( ) . into ( ) , Value :: Array ( a ) => { let mut ts = TokenStream2 :: new ( ) ; for value in a { let v = toml_to_ts ( value ) ; ts . extend ( quote ! ( v ) ) ; } quote ! ( ( ts ) ) } Value :: Table ( t ) => { let mut ts = TokenStream2 :: new ( ) ; for ( key , value ) in t { let v = toml_to_ts ( value ) ; ts . extend ( quote ! ( ( key v ) ) ) ; } quote ! ( ( ts ) ) } } }
Converts any TOML value to valid Rust types.
Converts any TOML value to valid Rust types .
input
Value