to_string

Function to_string 

Source
pub fn to_string<T: Serialize>(value: &T) -> Result<String, Error>
Expand description

Serialize a value to a TOON-formatted string

§Arguments

  • value - The value to serialize (must implement Serialize)

§Returns

A Result containing the TOON-formatted string or an error

§Example

use serde::Serialize;
use toon_rust::to_string;

#[derive(Serialize)]
struct Product {
    sku: String,
    qty: u32,
}

let product = Product { sku: "A1".to_string(), qty: 2 };
let toon = to_string(&product).unwrap();