about summary refs log tree commit diff
path: root/users/tazjin/rlox
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-02-27T12·17+0200
committertazjin <mail@tazj.in>2021-02-27T13·05+0000
commitda2dfb42c6c1cb3a63686be06e9ff04f445506b2 (patch)
tree435267a7bd36df5fa828feedd19c03d3ede0250a /users/tazjin/rlox
parent75750ba6835ae8ac3a97c24ca7ff5ebc1500f36d (diff)
chore(tazjin/rlox): Add From<Error> for Vec<Error> r/2236
This makes it easier to transition between the single/multi error
functions via ?

Change-Id: Ie027f4700da463a549be6f0d4a0022a9b8dc0d61
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2555
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'users/tazjin/rlox')
-rw-r--r--users/tazjin/rlox/src/bytecode/errors.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/bytecode/errors.rs b/users/tazjin/rlox/src/bytecode/errors.rs
index 513708df7e..99b2aa406c 100644
--- a/users/tazjin/rlox/src/bytecode/errors.rs
+++ b/users/tazjin/rlox/src/bytecode/errors.rs
@@ -37,4 +37,12 @@ impl From<ScannerError> for Error {
     }
 }
 
+// Convenience implementation as we're often dealing with vectors of
+// errors (to report as many issues as possible before terminating)
+impl From<Error> for Vec<Error> {
+    fn from(err: Error) -> Self {
+        vec![err]
+    }
+}
+
 pub type LoxResult<T> = Result<T, Error>;