about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/treewalk/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/rlox/src/treewalk/errors.rs')
-rw-r--r--users/tazjin/rlox/src/treewalk/errors.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/users/tazjin/rlox/src/treewalk/errors.rs b/users/tazjin/rlox/src/treewalk/errors.rs
index 3d5c28f9f3..54d2718eed 100644
--- a/users/tazjin/rlox/src/treewalk/errors.rs
+++ b/users/tazjin/rlox/src/treewalk/errors.rs
@@ -1,4 +1,5 @@
 use crate::treewalk::interpreter::Value;
+use std::fmt;
 
 #[derive(Debug)]
 pub enum ErrorKind {
@@ -33,6 +34,8 @@ pub struct Error {
     pub kind: ErrorKind,
 }
 
-pub fn report(err: &Error) {
-    eprintln!("[line {}] Error: {:?}", err.line, err.kind);
+impl fmt::Display for Error {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "[line {}] Error: {:?}", self.line, self.kind)
+    }
 }