Tomboy toml dom
For those who are struggling with Rust's cool syntax, our goal is to provide a TOML parser that's as easy as pointing to a menu and eating fast food.
Rustのイケてる構文に難儀している人のために、メニューを指差してファーストフードを食べるぐらい簡単な操作のTOMLパーサーを提供することを目標とします。
It's a tryal and error process. Specifications will change.
試行錯誤中です。 仕様はコロコロ変わるでしょう。
Tomboy is a pun.
トムボーイ(おてんば娘)は語呂合わせです。
References:
Run (実行)
Take a look at the repository.
リポジトリを見てください。
cargo run --example comment
cargo run --example cover
cargo run --example example
cargo run --example inline_table
cargo run --example key_value_number
cargo run --example key_value_wip
cargo run --example key_value
cargo run --example main
cargo run --example mix_array
cargo run --example table
Specification (仕様)
The specifications will gradually solidify.
仕様は少しずつ固めていきます。
You can think that you can't do anything that isn't written here.
ここに書かれていないことは何もできないと思ってもらって構いません。
extern crate tomboy_toml_dom;
use tomboy_toml_dom::model::layer310::Document;
use tomboy_toml_dom::Toml;
fn main() {
let toml_file = "./resource/example.toml";
let doc = Toml::from_file(toml_file);
test_age(&doc);
test_weight(&doc);
test_apple(&doc);
test_basic_strings_empty(&doc);
test_basic_strings_escape_backslash(&doc);
test_basic_strings_escape_double_quotation(&doc);
test_basic_strings_punctuation(&doc);
test_multiline_basic_strings_letter(&doc);
test_multiline_basic_strings_punctuation(&doc);
test_multiline_basic_strings_trim_start(&doc);
test_boolean_true(&doc);
test_boolean_false(&doc);
}
fn test_age(doc: &Document) {
if let Some(age) = doc.get_i128_by_key("age") {
println!("age = {}", age);
}
}
fn test_weight(doc: &Document) {
if let Some(age) = doc.get_f64_by_key("weight") {
println!("weight = {}", age);
}
}
fn test_apple(doc: &Document) {
if let Some(apple) = doc.get_str_by_key("apple") {
println!("apple = {}", apple);
}
}
fn test_basic_strings_empty(doc: &Document) {
if let Some(basic_strings_empty) = doc.get_str_by_key("basic_strings_empty") {
println!("basic_strings_empty = {}", basic_strings_empty);
}
}
fn test_basic_strings_escape_backslash(doc: &Document) {
if let Some(basic_strings_escape_backslash) =
doc.get_str_by_key("basic_strings_escape_backslash")
{
println!(
"basic_strings_escape_backslash = {}",
basic_strings_escape_backslash
);
}
}
fn test_basic_strings_escape_double_quotation(doc: &Document) {
if let Some(basic_strings_escape_double_quotation) =
doc.get_str_by_key("basic_strings_escape_double_quotation")
{
println!(
"basic_strings_escape_double_quotation = {}",
basic_strings_escape_double_quotation
);
}
}
fn test_basic_strings_punctuation(doc: &Document) {
if let Some(basic_strings_punctuation) = doc.get_str_by_key("basic_strings_punctuation") {
println!("basic_strings_punctuation = {}", basic_strings_punctuation);
}
}
fn test_multiline_basic_strings_letter(doc: &Document) {
if let Some(multiline_basic_strings_letter) =
doc.get_str_by_key("multiline_basic_strings_letter")
{
println!(
"multiline_basic_strings_letter = {}",
multiline_basic_strings_letter
);
}
}
fn test_multiline_basic_strings_punctuation(doc: &Document) {
if let Some(multiline_basic_strings_punctuation) =
doc.get_str_by_key("multiline_basic_strings_punctuation")
{
println!(
"multiline_basic_strings_punctuation = {}",
multiline_basic_strings_punctuation
);
}
}
fn test_multiline_basic_strings_trim_start(doc: &Document) {
if let Some(multiline_basic_strings_trim_start) =
doc.get_str_by_key("multiline_basic_strings_trim_start")
{
println!(
"multiline_basic_strings_trim_start = {}",
multiline_basic_strings_trim_start
);
}
}
fn test_boolean_true(doc: &Document) {
if let Some(adult) = doc.get_bool_by_key("adult") {
println!("adult = {}", adult);
}
}
fn test_boolean_false(doc: &Document) {
if let Some(student) = doc.get_bool_by_key("student") {
println!("student = {}", student);
}
}
TODO