Skip to content

Commit dc6ddd5

Browse files
committed
---
yaml --- r: 191213 b: refs/heads/try c: 8121cf0 h: refs/heads/master i: 191211: 1f6afc8 v: v3
1 parent 419f8a2 commit dc6ddd5

File tree

2 files changed

+59
-19
lines changed

2 files changed

+59
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 809a554fca2d0ebc2ba50077016fe282a4064752
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c64d671671aea2e44ee7fc6eb00ee75fc30ed7b9
5-
refs/heads/try: e3656bd81baa3c2cb5065da04f9debf378f99772
5+
refs/heads/try: 8121cf077c68fa1d18a1a538deb5acdf79c5e732
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libcore/fmt/builders.rs

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)
6363
impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
6464
/// Adds a new field to the generated struct output.
6565
#[unstable(feature = "core", reason = "method was just created")]
66-
pub fn field<S>(mut self, name: &str, value: &S) -> DebugStruct<'a, 'b>
67-
where S: fmt::Debug {
66+
#[inline]
67+
pub fn field(mut self, name: &str, value: &fmt::Debug) -> DebugStruct<'a, 'b> {
68+
self.field_inner(name, value);
69+
self
70+
}
71+
72+
fn field_inner(&mut self, name: &str, value: &fmt::Debug) {
6873
self.result = self.result.and_then(|_| {
6974
let prefix = if self.has_fields {
7075
","
@@ -81,13 +86,18 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
8186
});
8287

8388
self.has_fields = true;
84-
self
8589
}
8690

8791
/// Consumes the `DebugStruct`, finishing output and returning any error
8892
/// encountered.
8993
#[unstable(feature = "core", reason = "method was just created")]
94+
#[inline]
9095
pub fn finish(mut self) -> fmt::Result {
96+
self.finish_inner();
97+
self.result
98+
}
99+
100+
fn finish_inner(&mut self) {
91101
if self.has_fields {
92102
self.result = self.result.and_then(|_| {
93103
if self.is_pretty() {
@@ -97,7 +107,6 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
97107
}
98108
});
99109
}
100-
self.result
101110
}
102111

103112
fn is_pretty(&self) -> bool {
@@ -127,7 +136,13 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
127136
impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
128137
/// Adds a new field to the generated tuple struct output.
129138
#[unstable(feature = "core", reason = "method was just created")]
130-
pub fn field<S>(mut self, value: &S) -> DebugTuple<'a, 'b> where S: fmt::Debug {
139+
#[inline]
140+
pub fn field(mut self, value: &fmt::Debug) -> DebugTuple<'a, 'b> {
141+
self.field_inner(value);
142+
self
143+
}
144+
145+
fn field_inner(&mut self, value: &fmt::Debug) {
131146
self.result = self.result.and_then(|_| {
132147
let (prefix, space) = if self.has_fields {
133148
(",", " ")
@@ -144,13 +159,18 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
144159
});
145160

146161
self.has_fields = true;
147-
self
148162
}
149163

150164
/// Consumes the `DebugTuple`, finishing output and returning any error
151165
/// encountered.
152166
#[unstable(feature = "core", reason = "method was just created")]
167+
#[inline]
153168
pub fn finish(mut self) -> fmt::Result {
169+
self.finish_inner();
170+
self.result
171+
}
172+
173+
fn finish_inner(&mut self) {
154174
if self.has_fields {
155175
self.result = self.result.and_then(|_| {
156176
if self.is_pretty() {
@@ -160,7 +180,6 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
160180
}
161181
});
162182
}
163-
self.result
164183
}
165184

166185
fn is_pretty(&self) -> bool {
@@ -190,7 +209,13 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> Deb
190209
impl<'a, 'b: 'a> DebugSet<'a, 'b> {
191210
/// Adds a new entry to the set output.
192211
#[unstable(feature = "core", reason = "method was just created")]
193-
pub fn entry<S>(mut self, entry: &S) -> DebugSet<'a, 'b> where S: fmt::Debug {
212+
#[inline]
213+
pub fn entry(mut self, entry: &fmt::Debug) -> DebugSet<'a, 'b> {
214+
self.entry_inner(entry);
215+
self
216+
}
217+
218+
fn entry_inner(&mut self, entry: &fmt::Debug) {
194219
self.result = self.result.and_then(|_| {
195220
let prefix = if self.has_fields {
196221
","
@@ -207,21 +232,26 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
207232
});
208233

209234
self.has_fields = true;
210-
self
211235
}
212236

213237
/// Consumes the `DebugSet`, finishing output and returning any error
214238
/// encountered.
215239
#[unstable(feature = "core", reason = "method was just created")]
216-
pub fn finish(self) -> fmt::Result {
217-
self.result.and_then(|_| {
240+
#[inline]
241+
pub fn finish(mut self) -> fmt::Result {
242+
self.finish_inner();
243+
self.result
244+
}
245+
246+
fn finish_inner(&mut self) {
247+
self.result = self.result.and_then(|_| {
218248
let end = match (self.has_fields, self.is_pretty()) {
219249
(false, _) => "}",
220250
(true, false) => " }",
221251
(true, true) => "\n}",
222252
};
223253
self.fmt.write_str(end)
224-
})
254+
});
225255
}
226256

227257
fn is_pretty(&self) -> bool {
@@ -251,8 +281,13 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> Deb
251281
impl<'a, 'b: 'a> DebugMap<'a, 'b> {
252282
/// Adds a new entry to the map output.
253283
#[unstable(feature = "core", reason = "method was just created")]
254-
pub fn entry<K, V>(mut self, key: &K, value: &V) -> DebugMap<'a, 'b>
255-
where K: fmt::Debug, V: fmt::Debug {
284+
#[inline]
285+
pub fn entry(mut self, key: &fmt::Debug, value: &fmt::Debug) -> DebugMap<'a, 'b> {
286+
self.entry_inner(key, value);
287+
self
288+
}
289+
290+
fn entry_inner(&mut self, key: &fmt::Debug, value: &fmt::Debug) {
256291
self.result = self.result.and_then(|_| {
257292
let prefix = if self.has_fields {
258293
","
@@ -269,21 +304,26 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
269304
});
270305

271306
self.has_fields = true;
272-
self
273307
}
274308

275309
/// Consumes the `DebugMap`, finishing output and returning any error
276310
/// encountered.
277311
#[unstable(feature = "core", reason = "method was just created")]
278-
pub fn finish(self) -> fmt::Result {
279-
self.result.and_then(|_| {
312+
#[inline]
313+
pub fn finish(mut self) -> fmt::Result {
314+
self.finish_inner();
315+
self.result
316+
}
317+
318+
fn finish_inner(&mut self) {
319+
self.result = self.result.and_then(|_| {
280320
let end = match (self.has_fields, self.is_pretty()) {
281321
(false, _) => "}",
282322
(true, false) => " }",
283323
(true, true) => "\n}",
284324
};
285325
self.fmt.write_str(end)
286-
})
326+
});
287327
}
288328

289329
fn is_pretty(&self) -> bool {

0 commit comments

Comments
 (0)