File: string_as_model.rs

package info (click to toggle)
rust-nutmeg 0.1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 485 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Use a simple String as a Model, with no need to `impl Model`.

use std::fs::read_dir;
use std::io;
use std::thread::sleep;
use std::time::Duration;

fn main() -> io::Result<()> {
    let options = nutmeg::Options::default();
    let view = nutmeg::View::new(String::new(), options);
    for p in read_dir(".")? {
        let dir_entry = p?;
        view.update(|model| *model = dir_entry.path().display().to_string());
        sleep(Duration::from_millis(300));
    }
    Ok(())
}