Skip to content

Commit 440a30f

Browse files
author
bors-servo
committed
Auto merge of servo#85 - notriddle:master, r=SimonSapin
Add HeapSizeOf support. Part of servo/heapsize#5. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/85) <!-- Reviewable:end -->
2 parents f0f3e53 + 9e84a9f commit 440a30f

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ script:
99
- cargo build --verbose
1010
- cargo test --verbose
1111
- cargo doc --verbose
12+
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --features heap_size)
1213

1314
after_success: |
1415
[ $TRAVIS_RUST_VERSION = nightly ] &&

Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ optional = true
2222
[dependencies.serde_macros]
2323
optional = true
2424

25+
[dependencies.heapsize]
26+
version = "0.1.1"
27+
optional = true
28+
29+
[dependencies.heapsize_plugin]
30+
version = "0.0.1"
31+
optional = true
32+
2533
[dependencies]
2634
encoding = "0.2"
2735
matches = "0.1"
2836

2937
[features]
3038
serde-serialization = [ "serde", "serde_macros" ]
31-
39+
heap_size = [ "heapsize", "heapsize_plugin" ]

src/color.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use super::{Token, Parser, ToCss};
1111
/// A color with red, green, blue, and alpha components.
1212
#[derive(Clone, Copy, PartialEq, Debug)]
1313
#[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))]
14+
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
1415
pub struct RGBA {
1516
/// The red channel. Nominally in 0.0 ... 1.0.
1617
pub red: f32,
@@ -41,6 +42,7 @@ impl ToCss for RGBA {
4142

4243
/// A <color> value.
4344
#[derive(Clone, Copy, PartialEq, Debug)]
45+
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
4446
pub enum Color {
4547
/// The 'currentColor' keyword
4648
CurrentColor,

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#![cfg_attr(feature = "serde-serialization", feature(custom_derive))]
1010
#![cfg_attr(feature = "serde-serialization", feature(plugin))]
1111
#![cfg_attr(feature = "serde-serialization", plugin(serde_macros))]
12+
#![cfg_attr(feature = "heap_size", feature(custom_derive))]
13+
#![cfg_attr(feature = "heap_size", feature(plugin))]
14+
#![cfg_attr(feature = "heap_size", plugin(heapsize_plugin))]
1215

1316
/*!
1417
@@ -71,6 +74,7 @@ extern crate encoding;
7174
#[cfg(test)] extern crate tempdir;
7275
#[cfg(test)] extern crate rustc_serialize;
7376
#[cfg(feature = "serde-serialization")] extern crate serde;
77+
#[cfg(feature = "heap_size")] extern crate heapsize;
7478

7579
pub use tokenizer::{Token, NumericValue, PercentageValue, SourceLocation};
7680
pub use rules_and_declarations::{parse_important};

0 commit comments

Comments
 (0)