diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-09-30 17:25:09 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-09-30 17:25:09 +0200 |
| commit | 7cc279f7ae122f4c40592004dde89792c636b3c8 (patch) | |
| tree | a71d3567950c147d41bfa649ca6cd76edb47cc4f /src/diagnostic.rs | |
| parent | 3c3730425f0a9a4241c4f57cb7f4d00b71db201e (diff) | |
Replace line/column with byte positions 🔢
Diffstat (limited to 'src/diagnostic.rs')
| -rw-r--r-- | src/diagnostic.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/diagnostic.rs b/src/diagnostic.rs index 1bf9f42f..2548e1d5 100644 --- a/src/diagnostic.rs +++ b/src/diagnostic.rs @@ -4,6 +4,8 @@ //! layout on a best effort process, generating diagnostics for incorrect //! things. +use std::fmt::{self, Display, Formatter}; + /// A diagnostic that arose in parsing or layouting. #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] @@ -30,6 +32,15 @@ impl Diagnostic { } } +impl Display for Level { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + f.pad(match self { + Self::Warning => "warning", + Self::Error => "error", + }) + } +} + /// Construct a diagnostic with `Error` level. /// /// ``` |
