rust-ini icon indicating copy to clipboard operation
rust-ini copied to clipboard

expecting \"[Some('='), Some(':')]\" but found EOF

Open pikhovkin opened this issue 11 months ago • 1 comments

There is rust-ini==0.20.0 and a conf.ini

; conf.ini
[Book]
path=path/a/b
name=Some name
list=
    444
    555
    666

where last string is empty string.

I ran main.rs

use ini::Ini;

fn main() {
    let conf = Ini::load_from_file("./file.ini").unwrap();
    let section = conf.section(Some("Book")).unwrap();
    let path = section.get("path").unwrap();
    println!("{:?}: {:?}", section, path);
}

and got this err

thread 'main' panicked at src/main.rs:4:50:
called `Result::unwrap()` on an `Err` value: Parse(ParseError { line: 9, col: 1, msg: "expecting \"[Some('='), Some(':')]\" but found EOF." })
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1073:23
   4: rs_pull_repos::main
             at ./src/main.rs:4:16
   5: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Process finished with exit code 101

if I change conf.ini to

; file.ini
[Book]
path=path/a/b
name=Some name
list=
    444
    555
    666

where last string is 666.

The error will be

thread 'main' panicked at src/main.rs:4:50:
called `Result::unwrap()` on an `Err` value: Parse(ParseError { line: 8, col: 8, msg: "expecting \"[Some('='), Some(':')]\" but found EOF." })
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1073:23
   4: rs_pull_repos::main
             at ./src/main.rs:4:16
   5: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Process finished with exit code 101

pikhovkin avatar Mar 06 '24 20:03 pikhovkin

Multiline value is not supported by ini's standard.

zonyitoo avatar Mar 07 '24 03:03 zonyitoo