| { | ||
| "git": { | ||
| "sha1": "c83c90c05314e7334a96f34abaca4bf7f0ab1bf3" | ||
| "sha1": "02369743437d6fe24574e7bee04b6ff3ca83b111" | ||
| }, | ||
| "path_in_vcs": "utils/writeable" | ||
| } |
@@ -48,11 +48,11 @@ // This file is part of ICU4X. For terms of use, please see the file | ||
| } | ||
| .writeable_to_string(); | ||
| .write_to_string(); | ||
| WriteableMessage { | ||
| message: black_box(MEDIUM_STR), | ||
| } | ||
| .writeable_to_string(); | ||
| .write_to_string(); | ||
| WriteableMessage { | ||
| message: black_box(LONG_STR), | ||
| } | ||
| .writeable_to_string(); | ||
| .write_to_string(); | ||
| }); | ||
@@ -76,3 +76,3 @@ }); | ||
| } | ||
| .writeable_to_string() | ||
| .write_to_string() | ||
| .into_owned() | ||
@@ -86,3 +86,3 @@ }); | ||
| } | ||
| .writeable_to_string() | ||
| .write_to_string() | ||
| .into_owned() | ||
@@ -96,3 +96,3 @@ }); | ||
| } | ||
| .writeable_to_string() | ||
| .write_to_string() | ||
| .into_owned() | ||
@@ -105,3 +105,3 @@ }); | ||
| fn writeable_dyn_benches(c: &mut Criterion) { | ||
| // Same as writeable_to_string, but casts to a dyn fmt::Write | ||
| // Same as `write_to_string`, but casts to a `dyn fmt::Write` | ||
| fn writeable_dyn_to_string(w: &impl Writeable) -> String { | ||
@@ -108,0 +108,0 @@ let mut output = String::with_capacity(w.write_len().capacity()); |
+60
-70
@@ -18,5 +18,5 @@ # This file is automatically @generated by Cargo. | ||
| name = "autocfg" | ||
| version = "1.0.1" | ||
| version = "1.1.0" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" | ||
| checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" | ||
@@ -111,5 +111,5 @@ [[package]] | ||
| name = "crossbeam-channel" | ||
| version = "0.5.2" | ||
| version = "0.5.4" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" | ||
| checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" | ||
| dependencies = [ | ||
@@ -133,6 +133,7 @@ "cfg-if", | ||
| name = "crossbeam-epoch" | ||
| version = "0.9.6" | ||
| version = "0.9.8" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762" | ||
| checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" | ||
| dependencies = [ | ||
| "autocfg", | ||
| "cfg-if", | ||
@@ -147,5 +148,5 @@ "crossbeam-utils", | ||
| name = "crossbeam-utils" | ||
| version = "0.8.6" | ||
| version = "0.8.8" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" | ||
| checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" | ||
| dependencies = [ | ||
@@ -186,5 +187,5 @@ "cfg-if", | ||
| name = "getrandom" | ||
| version = "0.2.4" | ||
| version = "0.2.6" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" | ||
| checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" | ||
| dependencies = [ | ||
@@ -213,5 +214,5 @@ "cfg-if", | ||
| name = "icu_benchmark_macros" | ||
| version = "0.4.0" | ||
| version = "0.6.0" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "ed07c547df407bdec6dd7a2c498281f786c2dcebfcd503fe8269745eb13acc19" | ||
| checksum = "630329e6635e4e3f747fb91fa9c0c2b8c83c1f3a2e4e49a282eb497be8f86b46" | ||
@@ -241,5 +242,5 @@ [[package]] | ||
| name = "js-sys" | ||
| version = "0.3.56" | ||
| version = "0.3.57" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" | ||
| checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" | ||
| dependencies = [ | ||
@@ -257,11 +258,11 @@ "wasm-bindgen", | ||
| name = "libc" | ||
| version = "0.2.116" | ||
| version = "0.2.125" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74" | ||
| checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" | ||
| [[package]] | ||
| name = "log" | ||
| version = "0.4.14" | ||
| version = "0.4.17" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" | ||
| checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" | ||
| dependencies = [ | ||
@@ -273,5 +274,5 @@ "cfg-if", | ||
| name = "memchr" | ||
| version = "2.4.1" | ||
| version = "2.5.0" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" | ||
| checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" | ||
@@ -289,5 +290,5 @@ [[package]] | ||
| name = "num-traits" | ||
| version = "0.2.14" | ||
| version = "0.2.15" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" | ||
| checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" | ||
| dependencies = [ | ||
@@ -349,5 +350,5 @@ "autocfg", | ||
| name = "proc-macro2" | ||
| version = "1.0.36" | ||
| version = "1.0.38" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" | ||
| checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa" | ||
| dependencies = [ | ||
@@ -359,5 +360,5 @@ "unicode-xid", | ||
| name = "quote" | ||
| version = "1.0.15" | ||
| version = "1.0.18" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" | ||
| checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" | ||
| dependencies = [ | ||
@@ -369,5 +370,5 @@ "proc-macro2", | ||
| name = "rand" | ||
| version = "0.8.4" | ||
| version = "0.8.5" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" | ||
| checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" | ||
| dependencies = [ | ||
@@ -377,3 +378,2 @@ "libc", | ||
| "rand_core", | ||
| "rand_hc", | ||
| ] | ||
@@ -401,15 +401,6 @@ | ||
| [[package]] | ||
| name = "rand_hc" | ||
| version = "0.3.1" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" | ||
| dependencies = [ | ||
| "rand_core", | ||
| ] | ||
| [[package]] | ||
| name = "rayon" | ||
| version = "1.5.1" | ||
| version = "1.5.2" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" | ||
| checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" | ||
| dependencies = [ | ||
@@ -424,5 +415,5 @@ "autocfg", | ||
| name = "rayon-core" | ||
| version = "1.9.1" | ||
| version = "1.9.2" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" | ||
| checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4" | ||
| dependencies = [ | ||
@@ -432,3 +423,2 @@ "crossbeam-channel", | ||
| "crossbeam-utils", | ||
| "lazy_static", | ||
| "num_cpus", | ||
@@ -439,5 +429,5 @@ ] | ||
| name = "regex" | ||
| version = "1.5.4" | ||
| version = "1.5.5" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" | ||
| checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" | ||
| dependencies = [ | ||
@@ -491,11 +481,11 @@ "regex-syntax", | ||
| name = "semver" | ||
| version = "1.0.4" | ||
| version = "1.0.9" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" | ||
| checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" | ||
| [[package]] | ||
| name = "serde" | ||
| version = "1.0.136" | ||
| version = "1.0.137" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" | ||
| checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" | ||
@@ -514,5 +504,5 @@ [[package]] | ||
| name = "serde_derive" | ||
| version = "1.0.136" | ||
| version = "1.0.137" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" | ||
| checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" | ||
| dependencies = [ | ||
@@ -526,5 +516,5 @@ "proc-macro2", | ||
| name = "serde_json" | ||
| version = "1.0.78" | ||
| version = "1.0.81" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" | ||
| checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" | ||
| dependencies = [ | ||
@@ -538,5 +528,5 @@ "itoa 1.0.1", | ||
| name = "syn" | ||
| version = "1.0.86" | ||
| version = "1.0.93" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" | ||
| checksum = "04066589568b72ec65f42d65a1a52436e954b168773148893c020269563decf2" | ||
| dependencies = [ | ||
@@ -575,5 +565,5 @@ "proc-macro2", | ||
| name = "unicode-xid" | ||
| version = "0.2.2" | ||
| version = "0.2.3" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" | ||
| checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" | ||
@@ -599,5 +589,5 @@ [[package]] | ||
| name = "wasm-bindgen" | ||
| version = "0.2.79" | ||
| version = "0.2.80" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" | ||
| checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" | ||
| dependencies = [ | ||
@@ -610,5 +600,5 @@ "cfg-if", | ||
| name = "wasm-bindgen-backend" | ||
| version = "0.2.79" | ||
| version = "0.2.80" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" | ||
| checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" | ||
| dependencies = [ | ||
@@ -626,5 +616,5 @@ "bumpalo", | ||
| name = "wasm-bindgen-macro" | ||
| version = "0.2.79" | ||
| version = "0.2.80" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" | ||
| checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" | ||
| dependencies = [ | ||
@@ -637,5 +627,5 @@ "quote", | ||
| name = "wasm-bindgen-macro-support" | ||
| version = "0.2.79" | ||
| version = "0.2.80" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" | ||
| checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" | ||
| dependencies = [ | ||
@@ -651,11 +641,11 @@ "proc-macro2", | ||
| name = "wasm-bindgen-shared" | ||
| version = "0.2.79" | ||
| version = "0.2.80" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" | ||
| checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" | ||
| [[package]] | ||
| name = "web-sys" | ||
| version = "0.3.56" | ||
| version = "0.3.57" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" | ||
| checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" | ||
| dependencies = [ | ||
@@ -699,3 +689,3 @@ "js-sys", | ||
| name = "writeable" | ||
| version = "0.3.0" | ||
| version = "0.4.0" | ||
| dependencies = [ | ||
@@ -702,0 +692,0 @@ "criterion", |
+13
-3
@@ -15,5 +15,13 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| name = "writeable" | ||
| version = "0.3.0" | ||
| version = "0.4.0" | ||
| authors = ["The ICU4X Project Developers"] | ||
| include = ["src/**/*", "examples/**/*", "benches/**/*", "tests/**/*", "Cargo.toml", "LICENSE", "README.md"] | ||
| include = [ | ||
| "src/**/*", | ||
| "examples/**/*", | ||
| "benches/**/*", | ||
| "tests/**/*", | ||
| "Cargo.toml", | ||
| "LICENSE", | ||
| "README.md", | ||
| ] | ||
| description = "A more efficient alternative to fmt::Display" | ||
@@ -24,2 +32,3 @@ readme = "README.md" | ||
| resolver = "2" | ||
| [package.metadata.docs.rs] | ||
@@ -35,2 +44,3 @@ all-features = true | ||
| harness = false | ||
| [dev-dependencies.criterion] | ||
@@ -40,3 +50,3 @@ version = "0.3" | ||
| [dev-dependencies.icu_benchmark_macros] | ||
| version = "0.4" | ||
| version = "0.6" | ||
@@ -43,0 +53,0 @@ [dev-dependencies.rand] |
+5
-5
@@ -6,6 +6,6 @@ # writeable [](https://crates.io/crates/writeable) | ||
| It includes [`Writeable`], a core trait representing an object that can be written to a | ||
| sink implementing std::fmt::Write. It is an alternative to std::fmt::Display with the | ||
| sink implementing `std::fmt::Write`. It is an alternative to `std::fmt::Display` with the | ||
| addition of a function indicating the number of bytes to be written. | ||
| Writeable improves upon std::fmt::Display in two ways: | ||
| `Writeable` improves upon `std::fmt::Display` in two ways: | ||
@@ -15,5 +15,5 @@ 1. More efficient, since the sink can pre-allocate bytes. | ||
| Types implementing Writeable have a defaulted writeable_to_string function. | ||
| If desired, types implementing Writeable can manually implement ToString | ||
| to wrap writeable_to_string. | ||
| Types implementing Writeable have a defaulted [`write_to_string`](Writeable::write_to_string) | ||
| function. If desired, types implementing `Writeable` can manually implement `ToString` | ||
| to wrap `write_to_string`. | ||
@@ -20,0 +20,0 @@ ## Examples |
+9
-5
@@ -16,2 +16,4 @@ // This file is part of ICU4X. For terms of use, please see the file | ||
| let mut i = buf.len(); | ||
| #[allow(clippy::indexing_slicing)] | ||
| // TODO(#1668) Clippy exceptions need docs or fixing. | ||
| while n != 0 { | ||
@@ -26,2 +28,4 @@ i -= 1; | ||
| } | ||
| #[allow(clippy::indexing_slicing)] | ||
| // TODO(#1668) Clippy exceptions need docs or fixing. | ||
| let s = unsafe { core::str::from_utf8_unchecked(&buf[i..]) }; | ||
@@ -147,7 +151,7 @@ sink.write_str(s) | ||
| /// | ||
| /// let cow = "foo".writeable_to_string(); | ||
| /// let cow = "foo".write_to_string(); | ||
| /// assert!(matches!(cow, Cow::Borrowed(_))); | ||
| /// ``` | ||
| #[inline] | ||
| fn writeable_to_string(&self) -> Cow<str> { | ||
| fn write_to_string(&self) -> Cow<str> { | ||
| Cow::Borrowed(self) | ||
@@ -169,3 +173,3 @@ } | ||
| #[inline] | ||
| fn writeable_to_string(&self) -> Cow<str> { | ||
| fn write_to_string(&self) -> Cow<str> { | ||
| Cow::Borrowed(self) | ||
@@ -192,4 +196,4 @@ } | ||
| #[inline] | ||
| fn writeable_to_string(&self) -> Cow<str> { | ||
| (*self).writeable_to_string() | ||
| fn write_to_string(&self) -> Cow<str> { | ||
| (*self).write_to_string() | ||
| } | ||
@@ -196,0 +200,0 @@ } |
+42
-30
@@ -5,3 +5,13 @@ // This file is part of ICU4X. For terms of use, please see the file | ||
| // https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations | ||
| #![cfg_attr(not(test), no_std)] | ||
| #![cfg_attr( | ||
| not(test), | ||
| deny( | ||
| clippy::indexing_slicing, | ||
| clippy::unwrap_used, | ||
| clippy::expect_used, | ||
| clippy::panic | ||
| ) | ||
| )] | ||
@@ -11,6 +21,6 @@ //! `writeable` is a utility crate of the [`ICU4X`] project. | ||
| //! It includes [`Writeable`], a core trait representing an object that can be written to a | ||
| //! sink implementing std::fmt::Write. It is an alternative to std::fmt::Display with the | ||
| //! sink implementing `std::fmt::Write`. It is an alternative to `std::fmt::Display` with the | ||
| //! addition of a function indicating the number of bytes to be written. | ||
| //! | ||
| //! Writeable improves upon std::fmt::Display in two ways: | ||
| //! `Writeable` improves upon `std::fmt::Display` in two ways: | ||
| //! | ||
@@ -20,5 +30,5 @@ //! 1. More efficient, since the sink can pre-allocate bytes. | ||
| //! | ||
| //! Types implementing Writeable have a defaulted writeable_to_string function. | ||
| //! If desired, types implementing Writeable can manually implement ToString | ||
| //! to wrap writeable_to_string. | ||
| //! Types implementing Writeable have a defaulted [`write_to_string`](Writeable::write_to_string) | ||
| //! function. If desired, types implementing `Writeable` can manually implement `ToString` | ||
| //! to wrap `write_to_string`. | ||
| //! | ||
@@ -67,11 +77,12 @@ //! # Examples | ||
| /// A hint to help consumers of Writeable pre-allocate bytes before they call write_to. | ||
| /// A hint to help consumers of `Writeable` pre-allocate bytes before they call | ||
| /// [`write_to`](Writeable::write_to). | ||
| /// | ||
| /// This behaves like Iterator::size_hint: it is a tuple where the first element is the | ||
| /// This behaves like `Iterator::size_hint`: it is a tuple where the first element is the | ||
| /// lower bound, and the second element is the upper bound. If the upper bound is `None` | ||
| /// either there is no known upper bound, or the upper bound is larger than usize. | ||
| /// either there is no known upper bound, or the upper bound is larger than `usize`. | ||
| /// | ||
| /// LengthHint implements std::ops::{Add, Mul} and similar traits for easy composition. | ||
| /// During computation, the lower bound will saturate at usize::MAX, while the upper | ||
| /// bound will become None if usize::MAX is exceeded. | ||
| /// `LengthHint` implements std`::ops::{Add, Mul}` and similar traits for easy composition. | ||
| /// During computation, the lower bound will saturate at `usize::MAX`, while the upper | ||
| /// bound will become `None` if `usize::MAX` is exceeded. | ||
| #[derive(Debug, PartialEq, Eq, Copy, Clone)] | ||
@@ -85,3 +96,3 @@ pub struct LengthHint(pub usize, pub Option<usize>); | ||
| /// This is the exact length from write_to. | ||
| /// This is the exact length from `write_to`. | ||
| pub fn exact(n: usize) -> Self { | ||
@@ -91,3 +102,3 @@ Self(n, Some(n)) | ||
| /// This is at least the length from write_to. | ||
| /// This is at least the length from `write_to`. | ||
| pub fn at_least(n: usize) -> Self { | ||
@@ -97,3 +108,3 @@ Self(n, None) | ||
| /// This is at most the length from write_to. | ||
| /// This is at most the length from `write_to`. | ||
| pub fn at_most(n: usize) -> Self { | ||
@@ -103,3 +114,3 @@ Self(0, Some(n)) | ||
| /// The length from write_to is in between n and m. | ||
| /// The length from `write_to` is in between `n` and `m`. | ||
| pub fn between(n: usize, m: usize) -> Self { | ||
@@ -129,3 +140,3 @@ Self(Ord::min(n, m), Some(Ord::max(n, m))) | ||
| /// Returns whether the LengthHint indicates that the string is exactly 0 bytes long. | ||
| /// Returns whether the `LengthHint` indicates that the string is exactly 0 bytes long. | ||
| pub fn is_zero(&self) -> bool { | ||
@@ -142,3 +153,3 @@ self.1 == Some(0) | ||
| /// A sink that supports annotating parts of the string with Parts. | ||
| /// A sink that supports annotating parts of the string with `Part`s. | ||
| pub trait PartsWrite: fmt::Write { | ||
@@ -154,7 +165,7 @@ type SubPartsWrite: PartsWrite + ?Sized; | ||
| /// Writeable is an alternative to std::fmt::Display with the addition of a length function. | ||
| /// `Writeable` is an alternative to `std::fmt::Display` with the addition of a length function. | ||
| pub trait Writeable { | ||
| /// Writes bytes to the given sink. Errors from the sink are bubbled up. | ||
| /// The default implementation delegates to write_to_parts, and discards any | ||
| /// Part annotations. | ||
| /// The default implementation delegates to `write_to_parts`, and discards any | ||
| /// `Part` annotations. | ||
| fn write_to<W: fmt::Write + ?Sized>(&self, sink: &mut W) -> fmt::Result { | ||
@@ -187,5 +198,5 @@ struct CoreWriteAsPartsWrite<W: fmt::Write + ?Sized>(W); | ||
| /// Write bytes and Part annotations to the given sink. Errors from the | ||
| /// sink are bubbled up. The default implementation delegates to write_to, | ||
| /// and doesn't produce any Part annotations. | ||
| /// Write bytes and `Part` annotations to the given sink. Errors from the | ||
| /// sink are bubbled up. The default implementation delegates to `write_to`, | ||
| /// and doesn't produce any `Part` annotations. | ||
| fn write_to_parts<S: PartsWrite + ?Sized>(&self, sink: &mut S) -> fmt::Result { | ||
@@ -202,6 +213,6 @@ self.write_to(sink) | ||
| /// Creates a new String with the data from this Writeable. Like ToString, | ||
| /// Creates a new `String` with the data from this `Writeable`. Like `ToString`, | ||
| /// but smaller and faster. | ||
| /// | ||
| /// The default impl allocates an owned String. However, if it is possible to return a | ||
| /// The default impl allocates an owned `String`. However, if it is possible to return a | ||
| /// borrowed string, overwrite this method to return a `Cow::Borrowed`. | ||
@@ -224,3 +235,3 @@ /// | ||
| /// { | ||
| /// let s = w.writeable_to_string(); | ||
| /// let s = w.write_to_string(); | ||
| /// if s.is_ascii() { | ||
@@ -240,7 +251,8 @@ /// sink.write_str(&s) | ||
| /// fn make_string(w: &impl Writeable) -> String { | ||
| /// w.writeable_to_string().into_owned() | ||
| /// w.write_to_string().into_owned() | ||
| /// } | ||
| /// ``` | ||
| fn writeable_to_string(&self) -> Cow<str> { | ||
| fn write_to_string(&self) -> Cow<str> { | ||
| let mut output = String::with_capacity(self.write_len().capacity()); | ||
| #[allow(clippy::expect_used)] // TODO(#1668) Clippy exceptions need docs or fixing. | ||
| self.write_to(&mut output) | ||
@@ -296,3 +308,3 @@ .expect("impl Write for String is infallible"); | ||
| assert_eq!(actual_str, $expected_str, $($arg)*); | ||
| assert_eq!(actual_str, $crate::Writeable::writeable_to_string(actual_writeable), $($arg)+); | ||
| assert_eq!(actual_str, $crate::Writeable::write_to_string(actual_writeable), $($arg)+); | ||
| let length_hint = $crate::Writeable::write_len(actual_writeable); | ||
@@ -315,3 +327,3 @@ assert!(length_hint.0 <= actual_str.len(), $($arg)*); | ||
| assert_eq!(actual_str, $expected_str, $($arg)+); | ||
| assert_eq!(actual_str, $crate::Writeable::writeable_to_string(actual_writeable), $($arg)+); | ||
| assert_eq!(actual_str, $crate::Writeable::write_to_string(actual_writeable), $($arg)+); | ||
| assert_eq!(actual_parts, $expected_parts, $($arg)+); | ||
@@ -318,0 +330,0 @@ let length_hint = $crate::Writeable::write_len(actual_writeable); |
Sorry, the diff of this file is not supported yet