mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-13 23:17:49 +00:00
docx: fix clippy large_enum_variant on main (#779)
A field's buffered result items held an InlineObject inline, which grew past clippy's large_enum_variant limit with today's object changes. Box it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
48b2468f19
commit
7d1f6a07c1
1 file changed
+6
-4
@@ -41,9 +41,11 @@ enum Phase {
|
||||
Result,
|
||||
}
|
||||
|
||||
/// A buffered piece of a field's result. Objects are boxed: an inline object is much larger than
|
||||
/// a string.
|
||||
enum Item {
|
||||
Text(String),
|
||||
Obj(InlineObject),
|
||||
Obj(Box<InlineObject>),
|
||||
}
|
||||
|
||||
struct FieldState {
|
||||
@@ -787,7 +789,7 @@ impl Reader<'_> {
|
||||
for (it, p) in f.buf {
|
||||
match it {
|
||||
Item::Text(t) => self.emit_text(sc, pb, &t, &p),
|
||||
Item::Obj(o) => self.emit_obj(sc, pb, o, &p),
|
||||
Item::Obj(o) => self.emit_obj(sc, pb, *o, &p),
|
||||
}
|
||||
}
|
||||
self.emit_obj(sc, pb, InlineObject::FieldEnd, &f.props);
|
||||
@@ -828,7 +830,7 @@ impl Reader<'_> {
|
||||
for (it, p) in f.buf.drain(..) {
|
||||
match it {
|
||||
Item::Text(t) => pb.push_text(&t, &p),
|
||||
Item::Obj(o) => pb.push_obj(o, &p),
|
||||
Item::Obj(o) => pb.push_obj(*o, &p),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -849,7 +851,7 @@ impl Reader<'_> {
|
||||
match sink(sc) {
|
||||
Some(f) => {
|
||||
if f.phase == Phase::Result && f.buf.len() < 100_000 {
|
||||
f.buf.push((Item::Obj(o), props.clone()));
|
||||
f.buf.push((Item::Obj(Box::new(o)), props.clone()));
|
||||
}
|
||||
}
|
||||
_ => pb.push_obj(o, props),
|
||||
|
||||
Reference in new issue
Block a user