aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-15 02:48:54 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-15 02:48:54 -0500
commit6f8b8814e077da7f74c61fa73401fd3cb76e494c (patch)
tree9cc0bcf6b12057fc9e090d2b6a3d8b6fdf7bdef6
parent866b160b9c9db80afde0b5855380cfe36e0f532c (diff)
downloadvt100-rust-6f8b8814e077da7f74c61fa73401fd3cb76e494c.tar.gz
vt100-rust-6f8b8814e077da7f74c61fa73401fd3cb76e494c.zip
bump itoa
-rw-r--r--Cargo.toml2
-rw-r--r--src/term.rs21
2 files changed, 11 insertions, 12 deletions
diff --git a/Cargo.toml b/Cargo.toml
index e658dbb..41d814d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ categories = ["command-line-interface", "encoding"]
license = "MIT"
[dependencies]
-itoa = "0.4.8"
+itoa = "1.0.1"
log = "0.4.14"
unicode-width = "0.1.9"
vte = "0.10.1"
diff --git a/src/term.rs b/src/term.rs
index cd97365..ef44e46 100644
--- a/src/term.rs
+++ b/src/term.rs
@@ -86,13 +86,9 @@ impl BufWrite for MoveTo {
buf.extend_from_slice(b"\x1b[H");
} else {
buf.extend_from_slice(b"\x1b[");
- itoa::write(&mut *buf, self.row + 1)
- // write to a vec can never fail
- .unwrap();
+ extend_itoa(buf, self.row + 1);
buf.push(b';');
- itoa::write(&mut *buf, self.col + 1)
- // write to a vec can never fail
- .unwrap();
+ extend_itoa(buf, self.col + 1);
buf.push(b'H');
}
}
@@ -175,7 +171,7 @@ impl BufWrite for Attrs {
} else {
buf.push(b';');
}
- itoa::write(&mut *buf, $i).unwrap();
+ extend_itoa(buf, $i);
};
}
@@ -292,8 +288,7 @@ impl BufWrite for MoveRight {
1 => buf.extend_from_slice(b"\x1b[C"),
n => {
buf.extend_from_slice(b"\x1b[");
- // write to a vec can never fail
- itoa::write(&mut *buf, n).unwrap();
+ extend_itoa(buf, n);
buf.push(b'C');
}
}
@@ -325,8 +320,7 @@ impl BufWrite for EraseChar {
1 => buf.extend_from_slice(b"\x1b[X"),
n => {
buf.extend_from_slice(b"\x1b[");
- // write to a vec can never fail
- itoa::write(&mut *buf, n).unwrap();
+ extend_itoa(buf, n);
buf.push(b'X');
}
}
@@ -613,3 +607,8 @@ impl BufWrite for MouseProtocolEncoding {
}
}
}
+
+fn extend_itoa<I: itoa::Integer>(buf: &mut Vec<u8>, i: I) {
+ let mut itoa_buf = itoa::Buffer::new();
+ buf.extend_from_slice(itoa_buf.format(i).as_bytes());
+}