Skip to main content

convert

Function convert 

Source
pub fn convert(v: &Value, to: Kind) -> Option<Value>
Expand description

The value as another kind, where it reads as one; None where the change would be a guess.

What converts: a scalar to text, always, as the text it is written with; text to anything it parses as; an integer to a float and a whole float back; a datetime to another shape by dropping what the target lacks, or filling what it lacks with midnight, the epoch, or UTC; any value to a one-element array, and a one-element array back to its element. What does not: a boolean to a number and back, since true is not 1 in TOML; a float with a fraction to an integer; anything to an inline table. The returned value carries no decor; crate::set_value keeps the old one’s.