simple errors for lang-dev
add convenience From<&Span> for Label impl
bendn 2023-09-17
parent 77ed162 · commit a6ed061
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib.rs9
2 files changed, 10 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index bcc8650..31f8a66 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "lerr"
-version = "0.1.4"
+version = "0.1.5"
edition = "2021"
license = "MIT"
readme = "README.md"
diff --git a/src/lib.rs b/src/lib.rs
index 95f7717..fc5dc19 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -35,6 +35,15 @@ impl<S: ToString> From<(Span, S)> for Label {
}
}
+impl<S: ToString> From<(&Span, S)> for Label {
+ fn from((span, m): (&Span, S)) -> Self {
+ Self {
+ span: span.clone(),
+ message: m.to_string(),
+ }
+ }
+}
+
/// A note at the end of the diagnostic
#[derive(Debug)]
pub struct Note {