Skip to content

Commit 6093af4

Browse files
committed
Split Fields::named() into named() and push_named()
1 parent 4084261 commit 6093af4

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/lib.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -1101,28 +1101,30 @@ impl Field {
11011101
// ===== impl Fields =====
11021102

11031103
impl Fields {
1104-
fn named<T>(&mut self, name: &str, ty: T) -> &mut Self
1105-
where T: Into<Type>,
1104+
fn push_named(&mut self, field: Field) -> &mut Self
11061105
{
11071106
match *self {
11081107
Fields::Empty => {
1109-
*self = Fields::Named(vec![Field {
1110-
name: name.to_string(),
1111-
ty: ty.into(),
1112-
}]);
1108+
*self = Fields::Named(vec![field]);
11131109
}
11141110
Fields::Named(ref mut fields) => {
1115-
fields.push(Field {
1116-
name: name.to_string(),
1117-
ty: ty.into(),
1118-
});
1111+
fields.push(field);
11191112
}
11201113
_ => panic!("field list is named"),
1121-
}
1114+
};
11221115

11231116
self
11241117
}
11251118

1119+
fn named<T>(&mut self, name: &str, ty: T) -> &mut Self
1120+
where T: Into<Type>,
1121+
{
1122+
self.push_named(Field {
1123+
name: name.to_string(),
1124+
ty: ty.into(),
1125+
})
1126+
}
1127+
11261128
fn tuple<T>(&mut self, ty: T) -> &mut Self
11271129
where T: Into<Type>,
11281130
{

0 commit comments

Comments
 (0)