Change ToCss to take a CssWriter<W>

This more concrete wrapper type can write a prefix the very first time something
is written to it. This allows removing plenty of useless monomorphisations caused
by the former W/SequenceWriter<W> pair of types.
This commit is contained in:
Anthony Ramine 2018-01-22 19:58:01 +01:00
parent 3672856efa
commit cd8f96cc9e
89 changed files with 873 additions and 533 deletions

View file

@ -48,7 +48,7 @@ pub fn derive(input: DeriveInput) -> Tokens {
}
quote! {{
let mut writer = ::style_traits::values::SequenceWriter::new(&mut *dest, #separator);
let mut writer = ::style_traits::values::SequenceWriter::new(dest, #separator);
#expr
Ok(())
}}
@ -78,7 +78,10 @@ pub fn derive(input: DeriveInput) -> Tokens {
impl #impl_generics ::style_traits::ToCss for #name #ty_generics #where_clause {
#[allow(unused_variables)]
#[inline]
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result
fn to_css<W>(
&self,
dest: &mut ::style_traits::CssWriter<W>,
) -> ::std::fmt::Result
where
W: ::std::fmt::Write
{
@ -93,7 +96,10 @@ pub fn derive(input: DeriveInput) -> Tokens {
impls.append(quote! {
impl #impl_generics ::std::fmt::Debug for #name #ty_generics #where_clause {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
::style_traits::ToCss::to_css(self, f)
::style_traits::ToCss::to_css(
self,
&mut ::style_traits::CssWriter::new(f),
)
}
}
});