summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openpgp/src/macros.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/openpgp/src/macros.rs b/openpgp/src/macros.rs
index 9b9e84e2..ba09c91c 100644
--- a/openpgp/src/macros.rs
+++ b/openpgp/src/macros.rs
@@ -33,9 +33,10 @@ macro_rules! trace {
}
// Converts an indentation level to whitespace.
-pub(crate) fn indent(i: usize) -> &'static str {
+pub(crate) fn indent(i: isize) -> &'static str {
+ use std::convert::TryFrom;
let s = " ";
- &s[0..cmp::min(i, s.len())]
+ &s[0..cmp::min(usize::try_from(i).unwrap_or(0), s.len())]
}
macro_rules! tracer {
@@ -48,29 +49,29 @@ macro_rules! tracer {
// https://users.rust-lang.org/t/nested-macros-issue/8348/2
macro_rules! t {
( $fmt:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, $fmt) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, $fmt) };
( $fmt:expr, $a:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a)) };
( $fmt:expr, $a:expr, $b:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d, $e)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d, $e, $f)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr, $i:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr, $i:expr, $j:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr, $i:expr, $j:expr, $k:expr ) =>
- { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k)) };
+ { trace!($TRACE, "{}{}: {}", crate::macros::indent($indent), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k)) };
}
}
}