// Parse INI content
let ini_content = #|[database]
#|host=localhost
#|port=5432
#|
#|[server]
#|debug=true
#|
match @lib.parse(ini_content) {
Err(e) => println("Parse error: \{e}")
Ok(config) => {
// Access values
let host = config.get("database", "host") // Some("localhost")
let port = config.get_or_default("database", "port", "3306")
// Check existence
let has_db = config.has_section("database") // true
let has_ssl = config.has_key("database", "ssl") // false
// Modify configuration
config.set("cache", "ttl", "3600")
// Convert back to string
let ini_string = config.to_string()
}
}# Comments start with # or ;
global_setting=value
[section_name]
key1=value1
key2 : value2 # Both = and : separators supported
empty_value=
spaces = are trimmed automatically
; Another comment type
[another_section]
number=42
boolean=truemoon testmoon test --coverage