Bug 1471104 followup - Upgrade cssparser and revendor.

MozReview-Commit-ID: 74rBgkJEcYd

--HG--
extra : rebase_source : a30d17b3d7e24f1a61c01d1dc442d6ce60c1dde3
extra : source : 8ff268ee87b7392391a6b6aa981f9180c45b27b6
This commit is contained in:
Xidorn Quan 2018-06-27 10:43:21 +10:00
parent dadd7149ea
commit 46cae3d7aa
18 changed files with 105 additions and 437 deletions

22
Cargo.lock generated
View File

@ -442,7 +442,7 @@ dependencies = [
[[package]] [[package]]
name = "cssparser" name = "cssparser"
version = "0.23.9" version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -450,11 +450,11 @@ dependencies = [
"itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -803,7 +803,7 @@ name = "geckoservo"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1139,7 +1139,7 @@ name = "malloc_size_of"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0", "hashglobe 0.1.0",
"selectors 0.19.0", "selectors 0.19.0",
@ -1788,7 +1788,7 @@ name = "selectors"
version = "0.19.0" version = "0.19.0"
dependencies = [ dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1931,7 +1931,7 @@ dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible 0.0.1", "fallible 0.0.1",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1986,7 +1986,7 @@ version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1", "malloc_size_of 0.0.1",
"malloc_size_of_derive 0.0.1", "malloc_size_of_derive 0.0.1",
@ -1999,7 +1999,7 @@ name = "stylo_tests"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2557,7 +2557,7 @@ dependencies = [
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
"checksum cssparser 0.23.9 (registry+https://github.com/rust-lang/crates.io-index)" = "205647ffe2b63a9726a4c3bb6f31c7325e8ceff10e2f1b75a6fb7609e20419ea" "checksum cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)" = "495beddc39b1987b8e9f029354eccbd5ef88eb5f1cd24badb764dce338acf2e0"
"checksum cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f3a5383ae18dbfdeb569ed62019f5bddb2a95cd2d3833313c475a0d014777805" "checksum cssparser-macros 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f3a5383ae18dbfdeb569ed62019f5bddb2a95cd2d3833313c475a0d014777805"
"checksum cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b6557bdb1dc9647eae1cf7f5601b14cd45fc3c7ccf2df618387416fe542da6ea" "checksum cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b6557bdb1dc9647eae1cf7f5601b14cd45fc3c7ccf2df618387416fe542da6ea"
"checksum cstr-macros 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0472c17c83d3ec1af32fb6ee2b3ad56ae0b6e69355d63d1d30602055c34324a8" "checksum cstr-macros 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0472c17c83d3ec1af32fb6ee2b3ad56ae0b6e69355d63d1d30602055c34324a8"

View File

@ -24,7 +24,7 @@ servo = [
[dependencies] [dependencies]
app_units = "0.6" app_units = "0.6"
cssparser = "0.23.0" cssparser = "0.24.0"
euclid = "0.17" euclid = "0.17"
hashglobe = { path = "../hashglobe" } hashglobe = { path = "../hashglobe" }
hyper = { version = "0.10", optional = true } hyper = { version = "0.10", optional = true }

View File

@ -22,7 +22,7 @@ bench = []
[dependencies] [dependencies]
bitflags = "1.0" bitflags = "1.0"
matches = "0.1" matches = "0.1"
cssparser = "0.23.0" cssparser = "0.24.0"
log = "0.4" log = "0.4"
fnv = "1.0" fnv = "1.0"
phf = "0.7.18" phf = "0.7.18"

View File

@ -31,7 +31,7 @@ atomic_refcell = "0.1"
bitflags = "1.0" bitflags = "1.0"
byteorder = "1.0" byteorder = "1.0"
cfg-if = "0.1.0" cfg-if = "0.1.0"
cssparser = "0.23.0" cssparser = "0.24.0"
new_debug_unreachable = "1.0" new_debug_unreachable = "1.0"
encoding_rs = {version = "0.7", optional = true} encoding_rs = {version = "0.7", optional = true}
euclid = "0.17" euclid = "0.17"

View File

@ -15,7 +15,7 @@ gecko = []
[dependencies] [dependencies]
app_units = "0.6" app_units = "0.6"
cssparser = "0.23.0" cssparser = "0.24.0"
bitflags = "1.0" bitflags = "1.0"
euclid = "0.17" euclid = "0.17"
malloc_size_of = { path = "../malloc_size_of" } malloc_size_of = { path = "../malloc_size_of" }

View File

@ -15,7 +15,7 @@ gecko_debug = ["style/gecko_debug"]
[dependencies] [dependencies]
atomic_refcell = "0.1" atomic_refcell = "0.1"
cssparser = "0.23.0" cssparser = "0.24.0"
cstr = "0.1.2" cstr = "0.1.2"
libc = "0.2" libc = "0.2"
log = {version = "0.4", features = ["release_max_level_info"]} log = {version = "0.4", features = ["release_max_level_info"]}

View File

@ -13,7 +13,7 @@ doctest = false
[dependencies] [dependencies]
atomic_refcell = "0.1" atomic_refcell = "0.1"
cssparser = "0.23.0" cssparser = "0.24.0"
cstr = "0.1.2" cstr = "0.1.2"
env_logger = { version = "0.5", default-features = false } env_logger = { version = "0.5", default-features = false }
euclid = "0.17" euclid = "0.17"

View File

@ -12,7 +12,7 @@ doctest = false
[dependencies] [dependencies]
byteorder = "1.0" byteorder = "1.0"
app_units = "0.6" app_units = "0.6"
cssparser = "0.23.0" cssparser = "0.24.0"
euclid = "0.17" euclid = "0.17"
html5ever = "0.22" html5ever = "0.22"
parking_lot = "0.5" parking_lot = "0.5"

View File

@ -1 +1 @@
{"files":{".travis.yml":"e8f586288c39dbaebefdd391f68376e58f3a4c568a8dc3cd97c4a362194716dd","Cargo.toml":"007ec70e8421e1889e8f28645d08967af29fdc2fbafa520f2b50a636de09e528","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"c5781e673335f37ed3d7acb119f8ed33efdf6eb75a7094b7da2abe0c3230adb8","build.rs":"ce686e87cccb6aa85a8cd34688d809398c5a624f179fd9a172d1049892da3f4c","build/match_byte.rs":"0f7d39170e746d59deebf7894086f63ee39ea61fb161d24b0c7a3c1db3945e0d","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"c60f1b0ab7a2a6213e434604ee33f78e7ef74347f325d86d0b9192d8225ae1cc","src/cow_rc_str.rs":"541216f8ef74ee3cc5cbbc1347e5f32ed66588c401851c9a7d68b867aede1de0","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"a474ee88ef8f73fcb7b7272d426e5eafb4ad10d104797a5a188d1676c8180972","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"5c70fb542d1376cddab69922eeb4c05e4fcf8f413f27563a2af50f72a47c8f8c","src/parser.rs":"9ed4aec998221eb2d2ba99db2f9f82a02399fb0c3b8500627f68f5aab872adde","src/rules_and_declarations.rs":"be2c4f3f3bb673d866575b6cb6084f1879dff07356d583ca9a3595f63b7f916f","src/serializer.rs":"3e2dfc60613f885cb6f99abfc854fde2a1e00de507431bd2e51178b61abfd69b","src/size_of_tests.rs":"e5f63c8c18721cc3ff7a5407e84f9889ffa10e66da96e8510a696c3e00ad72d5","src/tests.rs":"80b02c80ab0fd580dad9206615c918e0db7dff63dfed0feeedb66f317d24b24b","src/tokenizer.rs":"429b2cba419cf8b923fbcc32d3bd34c0b39284ebfcb9fc29b8eb8643d8d5f312","src/unicode_range.rs":"191d50a1588e5c88608b84cfe9279def71f495f8e016fa093f90399bbd2b635f"},"package":"205647ffe2b63a9726a4c3bb6f31c7325e8ceff10e2f1b75a6fb7609e20419ea"} {"files":{".travis.yml":"e8f586288c39dbaebefdd391f68376e58f3a4c568a8dc3cd97c4a362194716dd","Cargo.toml":"99d0445140451d806afb253209d7fb144fe0879f52b2ba69da621237f8dd546b","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"c5781e673335f37ed3d7acb119f8ed33efdf6eb75a7094b7da2abe0c3230adb8","build.rs":"ce686e87cccb6aa85a8cd34688d809398c5a624f179fd9a172d1049892da3f4c","build/match_byte.rs":"31905ae3dba69fa82c1f13069df4cd056bb340d59ee5d177679425f105f203cf","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"c60f1b0ab7a2a6213e434604ee33f78e7ef74347f325d86d0b9192d8225ae1cc","src/cow_rc_str.rs":"541216f8ef74ee3cc5cbbc1347e5f32ed66588c401851c9a7d68b867aede1de0","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"a474ee88ef8f73fcb7b7272d426e5eafb4ad10d104797a5a188d1676c8180972","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"5c70fb542d1376cddab69922eeb4c05e4fcf8f413f27563a2af50f72a47c8f8c","src/parser.rs":"9ed4aec998221eb2d2ba99db2f9f82a02399fb0c3b8500627f68f5aab872adde","src/rules_and_declarations.rs":"622ce07c117a511d40ce595602d4f4730659a59273388f28553d1a2b0fac92ce","src/serializer.rs":"3e2dfc60613f885cb6f99abfc854fde2a1e00de507431bd2e51178b61abfd69b","src/size_of_tests.rs":"e5f63c8c18721cc3ff7a5407e84f9889ffa10e66da96e8510a696c3e00ad72d5","src/tests.rs":"4a9223b9d2dc982144499aee497515553fc3d9ec86ca7b2e62b6caa5d4a11570","src/tokenizer.rs":"429b2cba419cf8b923fbcc32d3bd34c0b39284ebfcb9fc29b8eb8643d8d5f312","src/unicode_range.rs":"191d50a1588e5c88608b84cfe9279def71f495f8e016fa093f90399bbd2b635f"},"package":"495beddc39b1987b8e9f029354eccbd5ef88eb5f1cd24badb764dce338acf2e0"}

View File

@ -12,7 +12,7 @@
[package] [package]
name = "cssparser" name = "cssparser"
version = "0.23.9" version = "0.24.0"
authors = ["Simon Sapin <simon.sapin@exyr.org>"] authors = ["Simon Sapin <simon.sapin@exyr.org>"]
build = "build.rs" build = "build.rs"
exclude = ["src/css-parsing-tests/**", "src/big-data-url.css"] exclude = ["src/css-parsing-tests/**", "src/big-data-url.css"]
@ -59,14 +59,14 @@ version = "0.7"
[dev-dependencies.rustc-serialize] [dev-dependencies.rustc-serialize]
version = "0.3" version = "0.3"
[build-dependencies.proc-macro2] [build-dependencies.proc-macro2]
version = "0.3" version = "0.4"
[build-dependencies.quote] [build-dependencies.quote]
version = "0.5" version = "0.6"
[build-dependencies.syn] [build-dependencies.syn]
version = "0.13" version = "0.14"
features = ["extra-traits", "fold"] features = ["extra-traits", "fold", "full"]
[features] [features]
bench = [] bench = []

View File

@ -9,7 +9,7 @@ use std::path::Path;
use syn; use syn;
use syn::fold::Fold; use syn::fold::Fold;
use proc_macro2::TokenStream; use proc_macro2::{Span, TokenStream};
struct MatchByteParser { struct MatchByteParser {
} }
@ -21,7 +21,7 @@ pub fn expand(from: &Path, to: &Path) {
let mut m = MatchByteParser {}; let mut m = MatchByteParser {};
let ast = m.fold_file(ast); let ast = m.fold_file(ast);
let code = ast.into_tokens().to_string().replace("{ ", "{\n").replace(" }", "\n}"); let code = ast.into_token_stream().to_string().replace("{ ", "{\n").replace(" }", "\n}");
File::create(to).unwrap().write_all(code.as_bytes()).unwrap(); File::create(to).unwrap().write_all(code.as_bytes()).unwrap();
} }
@ -82,7 +82,7 @@ fn expand_match_byte(body: &TokenStream) -> syn::Expr {
for (i, ref arm) in match_byte.arms.iter().enumerate() { for (i, ref arm) in match_byte.arms.iter().enumerate() {
let case_id = i + 1; let case_id = i + 1;
let index = case_id as isize; let index = case_id as isize;
let name = syn::Ident::from(format!("Case{}", case_id)); let name = syn::Ident::new(&format!("Case{}", case_id), Span::call_site());
for pat in &arm.pats { for pat in &arm.pats {
match pat { match pat {
@ -111,7 +111,7 @@ fn expand_match_byte(body: &TokenStream) -> syn::Expr {
} }
} }
}, },
&syn::Pat::Ident(syn::PatIdent { ident, .. }) => { &syn::Pat::Ident(syn::PatIdent { ref ident, .. }) => {
assert_eq!(wildcard, None); assert_eq!(wildcard, None);
wildcard = Some(ident); wildcard = Some(ident);
for byte in table.iter_mut() { for byte in table.iter_mut() {

View File

@ -7,7 +7,8 @@
use cow_rc_str::CowRcStr; use cow_rc_str::CowRcStr;
use parser::{parse_until_before, parse_until_after, parse_nested_block, ParserState}; use parser::{parse_until_before, parse_until_after, parse_nested_block, ParserState};
#[allow(unused_imports)] use std::ascii::AsciiExt; #[allow(unused_imports)] use std::ascii::AsciiExt;
use super::{Token, Parser, Delimiter, ParseError, BasicParseError, BasicParseErrorKind}; use super::{BasicParseError, BasicParseErrorKind, Delimiter};
use super::{ParseError, Parser, SourceLocation, Token};
/// Parse `!important`. /// Parse `!important`.
/// ///
@ -116,26 +117,40 @@ pub trait AtRuleParser<'i> {
/// End an at-rule which doesn't have block. Return the finished /// End an at-rule which doesn't have block. Return the finished
/// representation of the at-rule. /// representation of the at-rule.
/// ///
/// The location passed in is source location of the start of the prelude.
///
/// This is only called when `parse_prelude` returned `WithoutBlock`, and /// This is only called when `parse_prelude` returned `WithoutBlock`, and
/// either the `;` semicolon indeed follows the prelude, or parser is at /// either the `;` semicolon indeed follows the prelude, or parser is at
/// the end of the input. /// the end of the input.
fn rule_without_block(&mut self, prelude: Self::PreludeNoBlock) -> Self::AtRule { fn rule_without_block(
&mut self,
prelude: Self::PreludeNoBlock,
location: SourceLocation,
) -> Self::AtRule {
let _ = prelude; let _ = prelude;
let _ = location;
panic!("The `AtRuleParser::rule_without_block` method must be overriden \ panic!("The `AtRuleParser::rule_without_block` method must be overriden \
if `AtRuleParser::parse_prelude` ever returns `AtRuleType::WithoutBlock`.") if `AtRuleParser::parse_prelude` ever returns `AtRuleType::WithoutBlock`.")
} }
/// Parse the content of a `{ /* ... */ }` block for the body of the at-rule. /// Parse the content of a `{ /* ... */ }` block for the body of the at-rule.
/// ///
/// The location passed in is source location of the start of the prelude.
///
/// Return the finished representation of the at-rule /// Return the finished representation of the at-rule
/// as returned by `RuleListParser::next` or `DeclarationListParser::next`, /// as returned by `RuleListParser::next` or `DeclarationListParser::next`,
/// or `Err(())` to ignore the entire at-rule as invalid. /// or `Err(())` to ignore the entire at-rule as invalid.
/// ///
/// This is only called when `parse_prelude` returned `WithBlock`, and a block /// This is only called when `parse_prelude` returned `WithBlock`, and a block
/// was indeed found following the prelude. /// was indeed found following the prelude.
fn parse_block<'t>(&mut self, prelude: Self::PreludeBlock, input: &mut Parser<'i, 't>) fn parse_block<'t>(
-> Result<Self::AtRule, ParseError<'i, Self::Error>> { &mut self,
prelude: Self::PreludeBlock,
location: SourceLocation,
input: &mut Parser<'i, 't>,
) -> Result<Self::AtRule, ParseError<'i, Self::Error>> {
let _ = prelude; let _ = prelude;
let _ = location;
let _ = input; let _ = input;
Err(input.new_error(BasicParseErrorKind::AtRuleBodyInvalid)) Err(input.new_error(BasicParseErrorKind::AtRuleBodyInvalid))
} }
@ -178,12 +193,19 @@ pub trait QualifiedRuleParser<'i> {
/// Parse the content of a `{ /* ... */ }` block for the body of the qualified rule. /// Parse the content of a `{ /* ... */ }` block for the body of the qualified rule.
/// ///
/// The location passed in is source location of the start of the prelude.
///
/// Return the finished representation of the qualified rule /// Return the finished representation of the qualified rule
/// as returned by `RuleListParser::next`, /// as returned by `RuleListParser::next`,
/// or `Err(())` to ignore the entire at-rule as invalid. /// or `Err(())` to ignore the entire at-rule as invalid.
fn parse_block<'t>(&mut self, prelude: Self::Prelude, input: &mut Parser<'i, 't>) fn parse_block<'t>(
-> Result<Self::QualifiedRule, ParseError<'i, Self::Error>> { &mut self,
prelude: Self::Prelude,
location: SourceLocation,
input: &mut Parser<'i, 't>,
) -> Result<Self::QualifiedRule, ParseError<'i, Self::Error>> {
let _ = prelude; let _ = prelude;
let _ = location;
let _ = input; let _ = input;
Err(input.new_error(BasicParseErrorKind::QualifiedRuleInvalid)) Err(input.new_error(BasicParseErrorKind::QualifiedRuleInvalid))
} }
@ -421,11 +443,16 @@ where P: QualifiedRuleParser<'i, QualifiedRule = R, Error = E> +
}) })
} }
fn parse_at_rule<'i: 't, 't, P, E>(start: &ParserState, name: CowRcStr<'i>, fn parse_at_rule<'i: 't, 't, P, E>(
input: &mut Parser<'i, 't>, parser: &mut P) start: &ParserState,
-> Result<<P as AtRuleParser<'i>>::AtRule, name: CowRcStr<'i>,
(ParseError<'i, E>, &'i str)> input: &mut Parser<'i, 't>,
where P: AtRuleParser<'i, Error = E> { parser: &mut P,
) -> Result<<P as AtRuleParser<'i>>::AtRule, (ParseError<'i, E>, &'i str)>
where
P: AtRuleParser<'i, Error = E>
{
let location = input.current_source_location();
let delimiters = Delimiter::Semicolon | Delimiter::CurlyBracketBlock; let delimiters = Delimiter::Semicolon | Delimiter::CurlyBracketBlock;
// FIXME: https://github.com/rust-lang/rust/issues/42508 // FIXME: https://github.com/rust-lang/rust/issues/42508
let result = parse_until_before::<'i, 't, _, _, _>(input, delimiters, |input| { let result = parse_until_before::<'i, 't, _, _, _>(input, delimiters, |input| {
@ -434,7 +461,7 @@ fn parse_at_rule<'i: 't, 't, P, E>(start: &ParserState, name: CowRcStr<'i>,
match result { match result {
Ok(AtRuleType::WithoutBlock(prelude)) => { Ok(AtRuleType::WithoutBlock(prelude)) => {
match input.next() { match input.next() {
Ok(&Token::Semicolon) | Err(_) => Ok(parser.rule_without_block(prelude)), Ok(&Token::Semicolon) | Err(_) => Ok(parser.rule_without_block(prelude, location)),
Ok(&Token::CurlyBracketBlock) => Err(( Ok(&Token::CurlyBracketBlock) => Err((
input.new_unexpected_token_error(Token::CurlyBracketBlock), input.new_unexpected_token_error(Token::CurlyBracketBlock),
input.slice_from(start.position()), input.slice_from(start.position()),
@ -446,8 +473,10 @@ fn parse_at_rule<'i: 't, 't, P, E>(start: &ParserState, name: CowRcStr<'i>,
match input.next() { match input.next() {
Ok(&Token::CurlyBracketBlock) => { Ok(&Token::CurlyBracketBlock) => {
// FIXME: https://github.com/rust-lang/rust/issues/42508 // FIXME: https://github.com/rust-lang/rust/issues/42508
parse_nested_block::<'i, 't, _, _, _>(input, move |input| parser.parse_block(prelude, input)) parse_nested_block::<'i, 't, _, _, _>(
.map_err(|e| (e, input.slice_from(start.position()))) input,
move |input| parser.parse_block(prelude, location, input)
).map_err(|e| (e, input.slice_from(start.position())))
} }
Ok(&Token::Semicolon) => Err(( Ok(&Token::Semicolon) => Err((
input.new_unexpected_token_error(Token::Semicolon), input.new_unexpected_token_error(Token::Semicolon),
@ -469,9 +498,14 @@ fn parse_at_rule<'i: 't, 't, P, E>(start: &ParserState, name: CowRcStr<'i>,
} }
fn parse_qualified_rule<'i, 't, P, E>(input: &mut Parser<'i, 't>, parser: &mut P) fn parse_qualified_rule<'i, 't, P, E>(
-> Result<<P as QualifiedRuleParser<'i>>::QualifiedRule, ParseError<'i, E>> input: &mut Parser<'i, 't>,
where P: QualifiedRuleParser<'i, Error = E> { parser: &mut P,
) -> Result<<P as QualifiedRuleParser<'i>>::QualifiedRule, ParseError<'i, E>>
where
P: QualifiedRuleParser<'i, Error = E>
{
let location = input.current_source_location();
// FIXME: https://github.com/rust-lang/rust/issues/42508 // FIXME: https://github.com/rust-lang/rust/issues/42508
let prelude = parse_until_before::<'i, 't, _, _, _>(input, Delimiter::CurlyBracketBlock, |input| { let prelude = parse_until_before::<'i, 't, _, _, _>(input, Delimiter::CurlyBracketBlock, |input| {
parser.parse_prelude(input) parser.parse_prelude(input)
@ -481,7 +515,10 @@ fn parse_qualified_rule<'i, 't, P, E>(input: &mut Parser<'i, 't>, parser: &mut P
// Do this here so that we consume the `{` even if the prelude is `Err`. // Do this here so that we consume the `{` even if the prelude is `Err`.
let prelude = prelude?; let prelude = prelude?;
// FIXME: https://github.com/rust-lang/rust/issues/42508 // FIXME: https://github.com/rust-lang/rust/issues/42508
parse_nested_block::<'i, 't, _, _, _>(input, move |input| parser.parse_block(prelude, input)) parse_nested_block::<'i, 't, _, _, _>(
input,
move |input| parser.parse_block(prelude, location, input),
)
} }
_ => unreachable!() _ => unreachable!()
} }

View File

@ -785,13 +785,21 @@ impl<'i> AtRuleParser<'i> for JsonParser {
} }
} }
fn rule_without_block(&mut self, mut prelude: Vec<Json>) -> Json { fn rule_without_block(
&mut self,
mut prelude: Vec<Json>,
_location: SourceLocation,
) -> Json {
prelude.push(Json::Null); prelude.push(Json::Null);
Json::Array(prelude) Json::Array(prelude)
} }
fn parse_block<'t>(&mut self, mut prelude: Vec<Json>, input: &mut Parser<'i, 't>) fn parse_block<'t>(
-> Result<Json, ParseError<'i, ()>> { &mut self,
mut prelude: Vec<Json>,
_location: SourceLocation,
input: &mut Parser<'i, 't>,
) -> Result<Json, ParseError<'i, ()>> {
prelude.push(Json::Array(component_values_to_json(input))); prelude.push(Json::Array(component_values_to_json(input)));
Ok(Json::Array(prelude)) Ok(Json::Array(prelude))
} }
@ -806,8 +814,12 @@ impl<'i> QualifiedRuleParser<'i> for JsonParser {
Ok(component_values_to_json(input)) Ok(component_values_to_json(input))
} }
fn parse_block<'t>(&mut self, prelude: Vec<Json>, input: &mut Parser<'i, 't>) fn parse_block<'t>(
-> Result<Json, ParseError<'i, ()>> { &mut self,
prelude: Vec<Json>,
_location: SourceLocation,
input: &mut Parser<'i, 't>,
) -> Result<Json, ParseError<'i, ()>> {
Ok(JArray![ Ok(JArray![
"qualified rule", "qualified rule",
prelude, prelude,

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"13802d367c4f23465fb93d2579c1bea247cd7f8310fdd90b2d0f817ad93f17a0","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"fe0d3aa328d0e26c76f646c45197bc8c518257d31f3640baed096915b9bdf642","crates-io.md":"4de7b932987feadedd392855d166d0346e8f405190e8085a2e2f84c936a68959","src/bound.rs":"c85f8a617dcc90e5a9269305665d1610364fbb414c22cb5cadcedbe45f0c86e7","src/de.rs":"3e05e5b898f31c3ef96ed51f4e0a9b529ef6ff3240a980c450f6e4ed637c1ee3","src/fragment.rs":"9a8539d2bda80c62e4fdaf42816f371a2add62f9cf27b4646d90b636de40f56f","src/internals/ast.rs":"47b94e6b3ec03725c2c25e5764dca10286be02e975b11e5fe8e0879a1cbde424","src/internals/attr.rs":"5fc779f293fb33d2977dc0f7e86020acd9ce36fcbc90b199ba579d7a5542281b","src/internals/case.rs":"a07abcf7e2b7e4d72eaa1b3ce97d82b17c94533ed0ea88ea5d13d3cbf4394520","src/internals/check.rs":"ce47c103ec0683bdba07288834008977645b5f2e23382cabc27f6de927b724dc","src/internals/ctxt.rs":"f541083477396a13cf7abd3dab448907112f900a6395ddd42ed0a6717ada1016","src/internals/mod.rs":"414477f6fb187268ec87f917c0db9d328f4e6d188dfde93ab7479763e93e2aca","src/lib.rs":"b35a93042a3c4dec7d7871eb901e514ae28bc88183c49157a3ca4f7732aa7785","src/pretend.rs":"ea5aa1b338038ce1791cef34fd20091abb062cd61c0384ac931d0069413a5302","src/ser.rs":"6ac0b5ab9cd5a93486d7c1ca974afc95abadb11a4b923b33d04f44d1b42ffa5d","src/try.rs":"b9a10c8690d442a57fc7097d42c9a4f13034c7b4a30b7eb02d538fdbf8ae0a8d"},"package":null} {"files":{"Cargo.toml":"13802d367c4f23465fb93d2579c1bea247cd7f8310fdd90b2d0f817ad93f17a0","LICENSE-APACHE":"154397a08d0cb342110281129971868cd562542d0780b0d10722788cd11a1399","LICENSE-MIT":"72af89a828df52a9dcc42512ed64663b3b8d7961dd7a5586d44478eede82bc7a","README.md":"dbcc210d7f4962499db6d4cfa18658e26d05ee700c962a811cac911f095e22fd","crates-io.md":"d5b04b4dc9665c77da4afd1505b6859419ae6ae57b1fcb8d4ed7898181193936","src/bound.rs":"c85f8a617dcc90e5a9269305665d1610364fbb414c22cb5cadcedbe45f0c86e7","src/de.rs":"3e05e5b898f31c3ef96ed51f4e0a9b529ef6ff3240a980c450f6e4ed637c1ee3","src/fragment.rs":"9a8539d2bda80c62e4fdaf42816f371a2add62f9cf27b4646d90b636de40f56f","src/internals/ast.rs":"47b94e6b3ec03725c2c25e5764dca10286be02e975b11e5fe8e0879a1cbde424","src/internals/attr.rs":"5fc779f293fb33d2977dc0f7e86020acd9ce36fcbc90b199ba579d7a5542281b","src/internals/case.rs":"a07abcf7e2b7e4d72eaa1b3ce97d82b17c94533ed0ea88ea5d13d3cbf4394520","src/internals/check.rs":"ce47c103ec0683bdba07288834008977645b5f2e23382cabc27f6de927b724dc","src/internals/ctxt.rs":"f541083477396a13cf7abd3dab448907112f900a6395ddd42ed0a6717ada1016","src/internals/mod.rs":"414477f6fb187268ec87f917c0db9d328f4e6d188dfde93ab7479763e93e2aca","src/lib.rs":"b35a93042a3c4dec7d7871eb901e514ae28bc88183c49157a3ca4f7732aa7785","src/pretend.rs":"ea5aa1b338038ce1791cef34fd20091abb062cd61c0384ac931d0069413a5302","src/ser.rs":"6ac0b5ab9cd5a93486d7c1ca974afc95abadb11a4b923b33d04f44d1b42ffa5d","src/try.rs":"b9a10c8690d442a57fc7097d42c9a4f13034c7b4a30b7eb02d538fdbf8ae0a8d"},"package":null}

View File

@ -1,201 +1 @@
Apache License ../LICENSE-APACHE
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,25 +1 @@
Copyright (c) 2014 The Rust Project Developers ../LICENSE-MIT
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -1,104 +1 @@
# Serde &emsp; [![Build Status]][travis] [![Latest Version]][crates.io] [![Rustc Version 1.13+]][rustc] ../README.md
[Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master
[travis]: https://travis-ci.org/serde-rs/serde
[Latest Version]: https://img.shields.io/crates/v/serde.svg
[crates.io]: https://crates.io/crates/serde
[Rustc Version 1.13+]: https://img.shields.io/badge/rustc-1.13+-lightgray.svg
[rustc]: https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
---
You may be looking for:
- [An overview of Serde](https://serde.rs/)
- [Data formats supported by Serde](https://serde.rs/#data-formats)
- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html)
- [Examples](https://serde.rs/examples.html)
- [API documentation](https://docs.serde.rs/serde/)
- [Release notes](https://github.com/serde-rs/serde/releases)
## Serde in action
<details>
<summary>
Click to show Cargo.toml.
<a href="https://play.rust-lang.org/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">Run this code in the playground.</a>
</summary>
```toml
[dependencies]
# The core APIs, including the Serialize and Deserialize traits. Always
# required when using Serde.
serde = "1.0"
# Support for #[derive(Serialize, Deserialize)]. Required if you want Serde
# to work for structs and enums defined in your crate.
serde_derive = "1.0"
# Each data format lives in its own crate; the sample code below uses JSON
# but you may be using a different one.
serde_json = "1.0"
```
</details>
<p></p>
```rust
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
// Convert the Point to a JSON string.
let serialized = serde_json::to_string(&point).unwrap();
// Prints serialized = {"x":1,"y":2}
println!("serialized = {}", serialized);
// Convert the JSON string back to a Point.
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
// Prints deserialized = Point { x: 1, y: 2 }
println!("deserialized = {:?}", deserialized);
}
```
## Getting help
Serde developers live in the #serde channel on
[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a
good resource with generally faster response time but less specific knowledge
about Serde. If IRC is not your thing or you don't get a good response, we are
happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new)
as well.
## License
Serde is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

View File

@ -1,55 +1 @@
<!-- Serde readme rendered on crates.io --> ../crates-io.md
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
---
You may be looking for:
- [An overview of Serde](https://serde.rs/)
- [Data formats supported by Serde](https://serde.rs/#data-formats)
- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html)
- [Examples](https://serde.rs/examples.html)
- [API documentation](https://docs.serde.rs/serde/)
- [Release notes](https://github.com/serde-rs/serde/releases)
## Serde in action
```rust
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
// Convert the Point to a JSON string.
let serialized = serde_json::to_string(&point).unwrap();
// Prints serialized = {"x":1,"y":2}
println!("serialized = {}", serialized);
// Convert the JSON string back to a Point.
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
// Prints deserialized = Point { x: 1, y: 2 }
println!("deserialized = {:?}", deserialized);
}
```
## Getting help
Serde developers live in the #serde channel on
[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a
good resource with generally faster response time but less specific knowledge
about Serde. If IRC is not your thing or you don't get a good response, we are
happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new)
as well.