mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Require Clone for SelectorImpl so that all the types that are parameterized on it can derive(Clone).
It's not clear to me why this is a requirement, but it seems to be one. MozReview-Commit-ID: JM0DKjHHfT
This commit is contained in:
parent
2df9dc2b03
commit
32c624e585
1 changed files with 6 additions and 12 deletions
|
@ -42,7 +42,11 @@ macro_rules! with_all_bounds {
|
|||
|
||||
/// This trait allows to define the parser implementation in regards
|
||||
/// of pseudo-classes/elements
|
||||
pub trait SelectorImpl: Sized {
|
||||
///
|
||||
/// NB: We need Clone so that we can derive(Clone) on struct with that
|
||||
/// are parameterized on SelectorImpl. See
|
||||
/// https://github.com/rust-lang/rust/issues/26925
|
||||
pub trait SelectorImpl: Clone + Sized {
|
||||
type AttrValue: $($InSelector)*;
|
||||
type Identifier: $($InSelector)* + PrecomputedHash;
|
||||
type ClassName: $($InSelector)* + PrecomputedHash;
|
||||
|
@ -321,22 +325,12 @@ impl<Impl: SelectorImpl> ComplexSelector<Impl> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SelectorIter<'a, Impl: 'a + SelectorImpl> {
|
||||
iter: Rev<slice::Iter<'a, Component<Impl>>>,
|
||||
next_combinator: Option<Combinator>,
|
||||
}
|
||||
|
||||
// NB: Deriving this doesn't work for some reason, because it expects Impl to
|
||||
// implement Clone.
|
||||
impl<'a, Impl: 'a + SelectorImpl> Clone for SelectorIter<'a, Impl> {
|
||||
fn clone(&self) -> Self {
|
||||
SelectorIter {
|
||||
iter: self.iter.clone(),
|
||||
next_combinator: self.next_combinator.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Impl: 'a + SelectorImpl> SelectorIter<'a, Impl> {
|
||||
/// Prepares this iterator to point to the next sequence to the left,
|
||||
/// returning the combinator if the sequence was found.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue