File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,19 @@ impl UrlPartsBuilder {
6767 self . buf . push_str ( part) ;
6868 }
6969
70+ /// Push a component onto the buffer, using [`format!`]'s formatting syntax.
71+ ///
72+ /// # Examples
73+ ///
74+ /// Basic usage (equivalent to the example for [`UrlPartsBuilder::push`]):
75+ ///
76+ /// ```ignore (private-type)
77+ /// let mut builder = UrlPartsBuilder::new();
78+ /// builder.push("core");
79+ /// builder.push("str");
80+ /// builder.push_fmt(format_args!("{}.{}.html", "struct", "Bytes"));
81+ /// assert_eq!(builder.finish(), "core/str/struct.Bytes.html");
82+ /// ```
7083 crate fn push_fmt ( & mut self , args : fmt:: Arguments < ' _ > ) {
7184 if !self . buf . is_empty ( ) {
7285 self . buf . push ( '/' ) ;
Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ fn push_front_non_empty() {
4040 t ( builder, "nightly/core/str/struct.Bytes.html" ) ;
4141}
4242
43+ #[ test]
44+ fn push_fmt ( ) {
45+ let mut builder = UrlPartsBuilder :: new ( ) ;
46+ builder. push_fmt ( format_args ! ( "{}" , "core" ) ) ;
47+ builder. push ( "str" ) ;
48+ builder. push_front ( "nightly" ) ;
49+ builder. push_fmt ( format_args ! ( "{}.{}.html" , "struct" , "Bytes" ) ) ;
50+ t ( builder, "nightly/core/str/struct.Bytes.html" ) ;
51+ }
52+
4353#[ test]
4454fn collect ( ) {
4555 t ( [ "core" , "str" ] . into_iter ( ) . collect ( ) , "core/str" ) ;
You can’t perform that action at this time.
0 commit comments