File: cursor.rs

package info (click to toggle)
rust-chic 1.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 200 kB
  • sloc: makefile: 4
file content (24 lines) | stat: -rw-r--r-- 548 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
use chic::Error;
use std::io::Cursor;

fn main() {
    let cursor = Cursor::new(
        r#"This is an example
content of the slice
which will be annotated
with the list of annotations below.
"#,
    );

    let line = 1;
    let start = cursor.position() as usize;
    let end = cursor.get_ref().len() as usize;
    let code = cursor.into_inner();

    let msg = Error::new("expected type, found `x`")
        .error(line, start, end, code, "found `x`")
        .help("try using a foobs instead")
        .to_string();

    println!("{}", msg);
}