File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,19 @@ impl UrlPartsBuilder {
67
67
self . buf . push_str ( part) ;
68
68
}
69
69
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
+ /// ```
70
83
crate fn push_fmt ( & mut self , args : fmt:: Arguments < ' _ > ) {
71
84
if !self . buf . is_empty ( ) {
72
85
self . buf . push ( '/' ) ;
Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ fn push_front_non_empty() {
40
40
t ( builder, "nightly/core/str/struct.Bytes.html" ) ;
41
41
}
42
42
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
+
43
53
#[ test]
44
54
fn collect ( ) {
45
55
t ( [ "core" , "str" ] . into_iter ( ) . collect ( ) , "core/str" ) ;
You can’t perform that action at this time.
0 commit comments