File: test_parse.rs

package info (click to toggle)
rust-desktop-edit 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144 kB
  • sloc: makefile: 4
file content (26 lines) | stat: -rw-r--r-- 596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use desktop_edit::Desktop;
use std::str::FromStr;

fn main() {
    let input = r###"[Desktop Entry]
Name=Example Application
Type=Application
Exec=example
# This is a comment
Icon=example.png
"###;

    println!("Input:\n{}", input);
    println!("\nParsing...");
    match Desktop::from_str(input) {
        Ok(desktop) => {
            println!("Success! Groups: {}", desktop.groups().count());
            for group in desktop.groups() {
                println!("Group: {:?}", group.name());
            }
        }
        Err(e) => {
            println!("Error: {}", e);
        }
    }
}