Allow vector properties to be set by iterator

This commit is contained in:
Manish Goregaokar 2017-05-03 16:06:08 -07:00
parent dd3159f2f5
commit 33fb27c765
4 changed files with 174 additions and 78 deletions

View file

@ -1509,12 +1509,26 @@ pub mod style_structs {
% if longhand.logical:
${helpers.logical_setter(name=longhand.name)}
% else:
/// Set ${longhand.name}.
#[allow(non_snake_case)]
#[inline]
pub fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
self.${longhand.ident} = v;
}
% if longhand.is_vector:
/// Set ${longhand.name}.
#[allow(non_snake_case)]
#[inline]
pub fn set_${longhand.ident}<I>(&mut self, v: I)
where I: IntoIterator<Item = longhands::${longhand.ident}
::computed_value::single_value::T>,
I::IntoIter: ExactSizeIterator
{
self.${longhand.ident} = longhands::${longhand.ident}::computed_value
::T(v.into_iter().collect());
}
% else:
/// Set ${longhand.name}.
#[allow(non_snake_case)]
#[inline]
pub fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
self.${longhand.ident} = v;
}
% endif
/// Set ${longhand.name} from other struct.
#[allow(non_snake_case)]
#[inline]