From cffacc4dc4a46b525250772e87fd69a2f1c64dc2 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 11 Jun 2026 11:35:24 -0700 Subject: Split things out, made things easier to use. CrimError now has several constructors for different cases, so it's easier to use, using constructors is normalized now. Value has a load of From implementations now so it's much, much, much easier to use in practice. --- src/error.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index a2b6d96..a2349ee 100644 --- a/src/error.rs +++ b/src/error.rs @@ -11,15 +11,22 @@ pub struct CrimError { } impl CrimError { - pub fn new( position: Position, what: String ) -> Self { - CrimError { + pub fn parse( position: Position, what: String ) -> Self { + Self { position, what, } } + pub fn other(what: String) -> Self { + Self { + position: Position::none(), + what, + } + } + pub fn eos( context: &str ) -> Self { - CrimError { + Self { position: Position::none(), what: format!("Premature end of stream while looking for {}", context), } -- cgit v1.2.3