summaryrefslogtreecommitdiffstats
path: root/vendor/tabled/src/tables/util
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/tabled/src/tables/util
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tabled/src/tables/util')
-rw-r--r--vendor/tabled/src/tables/util/mod.rs2
-rw-r--r--vendor/tabled/src/tables/util/utf8_writer.rs29
2 files changed, 31 insertions, 0 deletions
diff --git a/vendor/tabled/src/tables/util/mod.rs b/vendor/tabled/src/tables/util/mod.rs
new file mode 100644
index 000000000..ea5453b8f
--- /dev/null
+++ b/vendor/tabled/src/tables/util/mod.rs
@@ -0,0 +1,2 @@
+#[cfg(feature = "std")]
+pub(crate) mod utf8_writer;
diff --git a/vendor/tabled/src/tables/util/utf8_writer.rs b/vendor/tabled/src/tables/util/utf8_writer.rs
new file mode 100644
index 000000000..d4fc515df
--- /dev/null
+++ b/vendor/tabled/src/tables/util/utf8_writer.rs
@@ -0,0 +1,29 @@
+use std::fmt;
+use std::io;
+
+pub(crate) struct UTF8Writer<W>(W);
+
+impl<W> UTF8Writer<W> {
+ pub(crate) fn new(writer: W) -> Self {
+ Self(writer)
+ }
+}
+
+impl<W> fmt::Write for UTF8Writer<W>
+where
+ W: io::Write,
+{
+ fn write_str(&mut self, s: &str) -> fmt::Result {
+ let mut buf = s.as_bytes();
+ loop {
+ let n = self.0.write(buf).map_err(|_| fmt::Error)?;
+ if n == buf.len() {
+ break;
+ }
+
+ buf = &buf[n..];
+ }
+
+ Ok(())
+ }
+}