Document and test UrlPartsBuilder::push_fmt
This commit is contained in:
parent
cef250d90b
commit
c7147e4e1a
@ -67,6 +67,19 @@ impl UrlPartsBuilder {
|
|||||||
self.buf.push_str(part);
|
self.buf.push_str(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Push a component onto the buffer, using [`format!`]'s formatting syntax.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// Basic usage (equivalent to the example for [`UrlPartsBuilder::push`]):
|
||||||
|
///
|
||||||
|
/// ```ignore (private-type)
|
||||||
|
/// let mut builder = UrlPartsBuilder::new();
|
||||||
|
/// builder.push("core");
|
||||||
|
/// builder.push("str");
|
||||||
|
/// builder.push_fmt(format_args!("{}.{}.html", "struct", "Bytes"));
|
||||||
|
/// assert_eq!(builder.finish(), "core/str/struct.Bytes.html");
|
||||||
|
/// ```
|
||||||
crate fn push_fmt(&mut self, args: fmt::Arguments<'_>) {
|
crate fn push_fmt(&mut self, args: fmt::Arguments<'_>) {
|
||||||
if !self.buf.is_empty() {
|
if !self.buf.is_empty() {
|
||||||
self.buf.push('/');
|
self.buf.push('/');
|
||||||
|
@ -40,6 +40,16 @@ fn push_front_non_empty() {
|
|||||||
t(builder, "nightly/core/str/struct.Bytes.html");
|
t(builder, "nightly/core/str/struct.Bytes.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn push_fmt() {
|
||||||
|
let mut builder = UrlPartsBuilder::new();
|
||||||
|
builder.push_fmt(format_args!("{}", "core"));
|
||||||
|
builder.push("str");
|
||||||
|
builder.push_front("nightly");
|
||||||
|
builder.push_fmt(format_args!("{}.{}.html", "struct", "Bytes"));
|
||||||
|
t(builder, "nightly/core/str/struct.Bytes.html");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn collect() {
|
fn collect() {
|
||||||
t(["core", "str"].into_iter().collect(), "core/str");
|
t(["core", "str"].into_iter().collect(), "core/str");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user