std.toml
Types
struct TomlError
Functions
Parse a string into TOML, return with a generic type by your given.
Parse a string into TOML, return with a generic type by your given.
Parse a string into TOML, return with a generic type by your given.
If the string is not a valid TOML, it will throw an std.toml.Error
.
nv
use std.toml;
struct User {
name: string,
id: int,
}
let user = try! toml.parse::<User>(`
name = "Sunli"
id = 123456
`);
assert_eq user.name, "Sunli";
assert_eq user.id, 123456;
Serialize a value to TOML string.
Serialize a value to TOML string.
Serialize a value to TOML string.
nv
use std.toml;
struct User {
name: string,
id: int,
profile: Profile
}
struct Profile {
city: string
}
let user = User {
name: "Sunli",
id: 123456,
profile: Profile {
city: "Wuhan"
}
};
let result = try! toml.to_string(user);
assert_eq result, `name = "Sunli"\nid = 123456\n\n[profile]\ncity = "Wuhan"\n`;