mirror of
https://codeberg.org/icewind/php-literal-parser.git
synced 2026-06-03 18:44:07 +02:00
switch to miette for error reporting
This commit is contained in:
parent
f24e69d99f
commit
097ed69b9e
9 changed files with 387 additions and 316 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use miette::DiagnosticResult;
|
||||
use php_literal_parser::{from_str, ParseError};
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
|
|
@ -7,7 +8,7 @@ struct Target {
|
|||
bars: Vec<u8>,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), ParseError> {
|
||||
fn main() -> DiagnosticResult<()> {
|
||||
let target = from_str(r#"["foo" => true, "bars" => [1, 2, 3, 4,]]"#)?;
|
||||
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use miette::DiagnosticResult;
|
||||
use php_literal_parser::{from_str, Value};
|
||||
|
||||
fn main() {
|
||||
fn main() -> DiagnosticResult<()> {
|
||||
let source = r###"
|
||||
array (
|
||||
"double" => "quote",
|
||||
|
|
@ -17,8 +18,6 @@ fn main() {
|
|||
)
|
||||
"###;
|
||||
|
||||
match from_str::<Value>(source) {
|
||||
Ok(result) => print!("{:#?}", result),
|
||||
Err(err) => eprint!("{}", err.with_source(source)),
|
||||
}
|
||||
println!("{:#?}", from_str::<Value>(source)?);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue