Skip to content

Commit 261bf36

Browse files
committed
Removed nits in rcdom and tokenizers
- Change tuple enum variant to struct enum variant - Use `Rc::ptr_eq` instead of special cast - Remove unneded `#![cfg_atr]`
1 parent e56372c commit 261bf36

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

xml5ever/src/rcdom.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ pub use self::ElementEnum::{Normal, Script, Template};
3838
pub enum ElementEnum {
3939
/// Regular element.
4040
Normal,
41-
/// A script element and its "already started" flag.
42-
/// https://html.spec.whatwg.org/multipage/#already-started
43-
Script(bool),
41+
/// A script element
42+
Script{
43+
/// Script element's already-started flag
44+
/// https://html.spec.whatwg.org/multipage/#already-started
45+
script_already_started: bool
46+
},
4447
/// A template element and its template contents.
4548
/// https://html.spec.whatwg.org/multipage/#template-contents
4649
Template(Handle),
@@ -106,10 +109,8 @@ fn new_node(node: NodeEnum) -> Handle {
106109
Handle(Rc::new(RefCell::new(Node::new(node))))
107110
}
108111

109-
#[allow(trivial_casts)]
110112
fn same_node(x: &Handle, y: &Handle) -> bool {
111-
// FIXME: This shouldn't really need to touch the borrow flags, right?
112-
(&*x.borrow() as *const Node) == (&*y.borrow() as *const Node)
113+
Rc::ptr_eq(&x, &y)
113114
}
114115

115116
fn append(new_parent: &Handle, child: Handle) {
@@ -232,7 +233,7 @@ impl TreeSink for RcDom {
232233
}
233234

234235
fn mark_script_already_started(&mut self, target: Handle) {
235-
if let Element(_, Script(ref mut script_already_started), _) = target.borrow_mut().node {
236+
if let Element(_, Script {ref mut script_already_started}, _) = target.borrow_mut().node {
236237
*script_already_started = true;
237238
} else {
238239
panic!("not a script element!");

xml5ever/tests/tokenizer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
#![cfg_attr(feature = "unstable", feature(start, test))]
11-
1210
extern crate rustc_serialize;
1311
extern crate test;
1412

0 commit comments

Comments
 (0)