mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Format jstraceable_derive #21373
This commit is contained in:
parent
6cb39fad47
commit
1cd092db63
1 changed files with 8 additions and 6 deletions
|
@ -3,15 +3,15 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
extern crate quote;
|
extern crate quote;
|
||||||
#[macro_use] extern crate syn;
|
#[macro_use]
|
||||||
#[macro_use] extern crate synstructure;
|
extern crate syn;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate synstructure;
|
||||||
|
|
||||||
decl_derive!([JSTraceable] => js_traceable_derive);
|
decl_derive!([JSTraceable] => js_traceable_derive);
|
||||||
|
|
||||||
fn js_traceable_derive(s: synstructure::Structure) -> quote::Tokens {
|
fn js_traceable_derive(s: synstructure::Structure) -> quote::Tokens {
|
||||||
let match_body = s.each(|binding| {
|
let match_body = s.each(|binding| Some(quote!(#binding.trace(tracer);)));
|
||||||
Some(quote!(#binding.trace(tracer);))
|
|
||||||
});
|
|
||||||
|
|
||||||
let ast = s.ast();
|
let ast = s.ast();
|
||||||
let name = ast.ident;
|
let name = ast.ident;
|
||||||
|
@ -19,7 +19,9 @@ fn js_traceable_derive(s: synstructure::Structure) -> quote::Tokens {
|
||||||
let mut where_clause = where_clause.unwrap_or(&parse_quote!(where)).clone();
|
let mut where_clause = where_clause.unwrap_or(&parse_quote!(where)).clone();
|
||||||
for param in ast.generics.type_params() {
|
for param in ast.generics.type_params() {
|
||||||
let ident = param.ident;
|
let ident = param.ident;
|
||||||
where_clause.predicates.push(parse_quote!(#ident: ::dom::bindings::trace::JSTraceable))
|
where_clause
|
||||||
|
.predicates
|
||||||
|
.push(parse_quote!(#ident: ::dom::bindings::trace::JSTraceable))
|
||||||
}
|
}
|
||||||
|
|
||||||
let tokens = quote! {
|
let tokens = quote! {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue