File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,10 @@ pub enum Argument {
175175 /// Number of decimal places to display for numbers.
176176 ///
177177 /// This is only applicable for numeric types.
178+ ///
179+ /// The precision cannot be equal to or greater than the maximum number
180+ /// of digits for the type. If it is, it will be set to the maximum
181+ /// number of digits minus one.
178182 Precision ( u8 ) ,
179183
180184 /// Truncate the output at the end when the specified maximum number of characters
@@ -262,7 +266,13 @@ macro_rules! impl_log_for_unsigned_integer {
262266 . iter( )
263267 . find( |arg| matches!( arg, Argument :: Precision ( _) ) )
264268 {
265- * p as usize
269+ // Precision cannot be equal to or greater than the maximum number
270+ // of digits for the type..
271+ if ( * p as usize ) >= MAX_DIGITS {
272+ MAX_DIGITS - 1
273+ } else {
274+ * p as usize
275+ }
266276 } else {
267277 0
268278 } ;
You can’t perform that action at this time.
0 commit comments