Skip to content

Commit 2bf4d74

Browse files
committed
Merge pull request #230 from jdm/underflow
Avoid an integer underflow panic. Fixes #229.
2 parents 3b40c6a + 6cf7495 commit 2bf4d74

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ fn rewrite_field(context: &RewriteContext,
10261026
-> Option<String> {
10271027
let name = &field.ident.node.to_string();
10281028
let overhead = name.len() + 2;
1029-
let expr = field.expr.rewrite(context, width - overhead, offset + overhead);
1029+
let expr = field.expr.rewrite(context, try_opt!(width.checked_sub(overhead)), offset + overhead);
10301030
expr.map(|s| format!("{}: {}", name, s))
10311031
}
10321032

0 commit comments

Comments
 (0)