summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2021-01-21 14:51:45 +0100
committerNeal H. Walfield <neal@pep.foundation>2021-01-21 17:36:08 +0100
commit8ea5c7a74d3b9d15f130c1e49b7a98249b782731 (patch)
treeb42cce8f3f530f778c3a4715bccd25f69c039f42
parent3406e0f4ee06c545b83a8e9379d1ae6359546e98 (diff)
openpgp: Improve Debug output of RegexSet.
-rw-r--r--openpgp/src/regex/mod.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/openpgp/src/regex/mod.rs b/openpgp/src/regex/mod.rs
index 8b139235..c61878a1 100644
--- a/openpgp/src/regex/mod.rs
+++ b/openpgp/src/regex/mod.rs
@@ -239,6 +239,7 @@
//! ```
use std::borrow::Borrow;
+use std::fmt;
use lalrpop_util::ParseError;
use regex_syntax::hir::{self, Hir};
@@ -536,13 +537,32 @@ assert_send_and_sync!(RegexSet_);
/// See the [module-level documentation] for more details.
///
/// [module-level documentation]: index.html
-#[derive(Clone, Debug)]
+#[derive(Clone)]
pub struct RegexSet {
re_set: RegexSet_,
disable_sanitizations: bool,
}
assert_send_and_sync!(RegexSet);
+impl fmt::Debug for RegexSet {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let mut d = f.debug_struct("RegexSet");
+ match self.re_set {
+ RegexSet_::Everything => {
+ d.field("regex", &"<Everything>")
+ }
+ RegexSet_::Invalid => {
+ d.field("regex", &"<Invalid>")
+ }
+ RegexSet_::Regex(ref r) => {
+ d.field("regex", &r.regex)
+ }
+ }
+ .field("sanitizations", &!self.disable_sanitizations)
+ .finish()
+ }
+}
+
impl RegexSet {
/// Parses and compiles the regular expressions.
///