[librsvg: 15/32] impl Display for DefsLookupErrorKind
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 15/32] impl Display for DefsLookupErrorKind
- Date: Fri, 4 Dec 2020 21:11:31 +0000 (UTC)
commit 7e50c99b2c09c7f18a0ad63d4923afdd9deb2ff1
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Nov 26 13:20:37 2020 -0600
impl Display for DefsLookupErrorKind
In preparation for not exposing this enum to the public API, we'll
have a way to print it.
src/error.rs | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/src/error.rs b/src/error.rs
index 4a8a6da2..a1957b29 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -116,6 +116,18 @@ pub enum DefsLookupErrorKind {
NotFound,
}
+impl fmt::Display for DefsLookupErrorKind {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match *self {
+ DefsLookupErrorKind::HrefError(_) => write!(f, "invalid URL"),
+ DefsLookupErrorKind::CannotLookupExternalReferences => {
+ write!(f, "cannot lookup references to elements in external files")
+ }
+ DefsLookupErrorKind::NotFound => write!(f, "not found"),
+ }
+ }
+}
+
/// Errors that can happen while rendering or measuring an SVG document.
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]