Skip to content

Commit fa7baa1

Browse files
committed
Refactor ResolveState::push_list_index() to use write!()
This fixes clippy "warning: `format!(..)` appended to existing `String`".
1 parent 01bee60 commit fa7baa1

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/refs/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ pub struct ResolveState {
3030

3131
impl ResolveState {
3232
/// Pushes the provided index into the last element of current_keys as `[idx]`.
33-
pub(crate) fn push_list_index(&mut self, idx: usize) {
33+
pub(crate) fn push_list_index(&mut self, idx: usize) -> std::fmt::Result {
34+
use std::fmt::Write;
3435
let mut kcount = self.current_keys.len();
3536
if kcount == 0 {
3637
self.current_keys.push(String::new());
3738
kcount = 1;
3839
}
39-
self.current_keys[kcount - 1].push_str(&format!("[{idx}]"));
40+
write!(&mut self.current_keys[kcount - 1], "[{idx}]")
4041
}
4142

4243
/// Pushes mapping key into the `current_keys` list. If possible, the provided value is

src/types/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl Value {
554554
// Sequence either, since there's no potential to start recursing again, if
555555
// we've fully interpolated a Sequence.
556556
let mut st = state.clone();
557-
st.push_list_index(idx);
557+
st.push_list_index(idx)?;
558558
let e = it.interpolate(root, &mut st)?;
559559
seq.push(e);
560560
}

0 commit comments

Comments
 (0)