Avoid an integer underflow panic. Fixes #229.
This commit is contained in:
parent
b59ab9c13f
commit
6cf74956b3
1 changed files with 1 additions and 1 deletions
|
@ -1026,7 +1026,7 @@ fn rewrite_field(context: &RewriteContext,
|
||||||
-> Option<String> {
|
-> Option<String> {
|
||||||
let name = &field.ident.node.to_string();
|
let name = &field.ident.node.to_string();
|
||||||
let overhead = name.len() + 2;
|
let overhead = name.len() + 2;
|
||||||
let expr = field.expr.rewrite(context, width - overhead, offset + overhead);
|
let expr = field.expr.rewrite(context, try_opt!(width.checked_sub(overhead)), offset + overhead);
|
||||||
expr.map(|s| format!("{}: {}", name, s))
|
expr.map(|s| format!("{}: {}", name, s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue