mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Support unit variants when deriving ToCss
This commit is contained in:
parent
7d09ce0495
commit
45e8b0e8c7
14 changed files with 71 additions and 242 deletions
|
@ -8,8 +8,15 @@ use app_units::Au;
|
|||
use cssparser::UnicodeRange;
|
||||
use std::fmt;
|
||||
|
||||
/// The real `ToCss` trait can't be implemented for types in crates that don't
|
||||
/// depend on each other.
|
||||
/// Serialises a value according to its CSS representation.
|
||||
///
|
||||
/// This trait is derivable with `#[derive(ToCss)]`, with the following behaviour:
|
||||
/// * unit variants get serialised as the `snake-case` representation
|
||||
/// of their name;
|
||||
/// * unit variants whose name starts with "Moz" or "Webkit" are prepended
|
||||
/// with a "-";
|
||||
/// * variants with fields get serialised as the space-separated serialisations
|
||||
/// of their fields.
|
||||
pub trait ToCss {
|
||||
/// Serialize `self` in CSS syntax, writing to `dest`.
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue