1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
//! This module contains types for the selectors of a rule.
//!
//! Basically, in a rule like `p.foo, .foo p { some: thing; }` there
//! is a `Selectors` object which contains two `Selector` objects, one
//! for `p.foo` and one for `.foo p`.
//!
//! This _may_ change to a something like a tree of operators with
//! leafs of simple selectors in some future release.
use super::{is_not, CssString, Value};
use crate::input::SourcePos;
use crate::parser::css::{selector, selector_parts, selectors};
use crate::parser::{input_span, ParseError};
use crate::value::ListSeparator;
use std::fmt;
use std::io::Write;
mod attribute;
mod cssselectorset;
mod logical;
mod pseudo;
mod selectorset;
pub(crate) use cssselectorset::CssSelectorSet;
pub(crate) use logical::Selector as LogicalSelector;
/// A full set of selectors.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub struct Selectors {
s: Vec<Selector>,
}
impl Selectors {
/// Create a root (empty) selector.
pub fn root() -> Self {
Self {
s: vec![Selector::root()],
}
}
/// Return true if this is a root (empty) selector.
pub fn is_root(&self) -> bool {
self.s == [Selector::root()]
}
/// Create a new `Selectors` from a vec of selectors.
pub fn new(s: Vec<Selector>) -> Self {
if s.is_empty() {
Self::root()
} else {
Self { s }
}
}
/// Validate that this selector is ok to use in css.
///
/// `Selectors` can contain backref (`&`), but those must be
/// resolved before using the `Selectors` in css.
pub fn css_ok(self) -> Result<Self, BadSelector> {
if self.has_backref() {
let sel = self.to_string();
Err(BadSelector::Backref(input_span(sel)))
} else {
Ok(self)
}
}
/// Get the first of these selectors (or the root selector if empty).
pub(crate) fn one(&self) -> Selector {
self.s.first().cloned().unwrap_or_else(Selector::root)
}
/// Create the full selector for when self is used inside a parent selector.
pub(crate) fn inside(&self, parent: &SelectorCtx) -> Self {
SelectorCtx::from(self.clone()).inside(parent).real()
}
/// True if any of the selectors contains a backref (`&`).
pub(crate) fn has_backref(&self) -> bool {
self.s.iter().any(Selector::has_backref)
}
/// Get a vec of the non-placeholder selectors in self.
pub fn no_placeholder(&self) -> Option<Self> {
let s = self
.s
.iter()
.filter_map(Selector::no_placeholder)
.collect::<Vec<_>>();
if s.is_empty() {
None
} else {
Some(Self { s })
}
}
fn no_leading_combinator(mut self) -> Option<Self> {
self.s.retain(|s| !s.has_leading_combinator());
if self.s.is_empty() {
None
} else {
Some(self)
}
}
/// Get these selectors with a specific backref selector.
///
/// Used to create `@at-root` contexts, to have `&` work in them.
pub(crate) fn with_backref(self, context: Selector) -> SelectorCtx {
SelectorCtx::from(self).inside(&SelectorCtx {
s: Self::root(),
backref: context,
})
}
/// Return true if any of these selectors ends with a combinator
pub fn has_trailing_combinator(&self) -> bool {
self.s.iter().any(Selector::has_trailing_combinator)
}
}
impl From<Selectors> for Value {
/// Create a css `Value` representing a set of selectors.
///
/// The result will be a comma-separated [list](Value::List) of
/// space-separated lists of strings, or [null](Value::Null) if
/// this is a root (empty) selector.
fn from(sel: Selectors) -> Self {
if sel.is_root() {
return Self::Null;
}
let content = sel
.s
.iter()
.map(|s: &Selector| {
let (mut v, last) = s.0.iter().fold(
(vec![], Option::<String>::None),
|(mut v, mut last), part| {
match part {
SelectorPart::Descendant => {
if let Some(last) = last.take() {
v.push(last.into());
}
}
SelectorPart::RelOp(op) => {
if let Some(last) = last.take() {
v.push(last.into());
}
v.push(char::from(*op).to_string().into());
}
part => {
last = Some(match last {
Some(last) => format!("{last}{part}"),
None => part.to_string(),
});
}
}
(v, last)
},
);
if let Some(last) = last {
v.push(last.into());
}
Self::List(v, Some(ListSeparator::Space), false)
})
.collect::<Vec<_>>();
Self::List(content, Some(ListSeparator::Comma), false)
}
}
/// A full set of selectors with a separate backref.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub struct SelectorCtx {
/// The actual selectors.
s: Selectors,
backref: Selector,
}
impl SelectorCtx {
/// Create a root (empty) selector.
pub fn root() -> Self {
Selectors::root().into()
}
pub(crate) fn root_with_backref(context: Selector) -> Self {
Self {
s: Selectors::root(),
backref: context,
}
}
/// Return true if this is a root (empty) selector.
pub fn is_root(&self) -> bool {
self.s.is_root() && self.backref == Selector::root()
}
pub(crate) fn real(&self) -> Selectors {
self.s.clone()
}
/// Remove the first of these selectors (or the root selector if empty).
pub(crate) fn one(&self) -> Selector {
self.s.one()
}
/// Create the full selector for when self is used inside a parent selector.
pub(crate) fn inside(&self, parent: &Self) -> Self {
let mut result = Vec::new();
for p in &parent.s.s {
for s in &self.s.s {
result.push(p.join(s, &parent.backref));
}
}
Self {
s: Selectors::new(result),
backref: parent.backref.clone(),
}
}
}
impl From<Selectors> for SelectorCtx {
fn from(value: Selectors) -> Self {
Self {
s: value,
backref: Selector::root(),
}
}
}
impl TryFrom<Value> for SelectorCtx {
type Error = BadSelector;
fn try_from(v: Value) -> Result<Self, Self::Error> {
Selectors::try_from(v).map(Into::into)
}
}
impl TryFrom<Value> for Selectors {
type Error = BadSelector;
fn try_from(v: Value) -> Result<Self, Self::Error> {
value_to_selectors(&v).map_err(move |e| e.ctx(v))
}
}
fn value_to_selectors(v: &Value) -> Result<Selectors, BadSelector0> {
match v {
Value::List(vv, s, _) => match s {
Some(ListSeparator::Comma) => {
let vv = vv
.iter()
.map(value_to_selector)
.collect::<Result<_, _>>()?;
Ok(Selectors::new(vv))
}
Some(ListSeparator::Space) => {
let (mut outer, last) = vv.iter().try_fold(
(vec![], vec![]),
|(mut outer, mut a), v: &Value| {
if let Ok(ref mut s) = check_selector_str(v) {
push_descendant(&mut a, s);
} else {
let mut s = parse_selectors_str(v)?;
if let Some(f) = s.s.first_mut() {
push_descendant(&mut a, f);
std::mem::swap(&mut a, &mut f.0);
}
if let Some(last) = s.s.pop() {
a = last.0;
}
outer.extend(s.s);
}
Result::<_, BadSelector0>::Ok((outer, a))
},
)?;
outer.push(Selector(last));
Ok(Selectors::new(outer))
}
_ => Err(BadSelector0::Value),
},
Value::Literal(s) => {
if s.value().is_empty() {
Ok(Selectors::root())
} else {
let span = input_span(s.value());
Ok(ParseError::check(selectors(span.borrow()))?)
}
}
_ => Err(BadSelector0::Value),
}
}
fn check_selector_str(v: &Value) -> Result<Selector, BadSelector0> {
match v {
Value::Literal(s) => {
if s.value().is_empty() {
Ok(Selector::root())
} else {
let span = input_span(s.value());
Ok(ParseError::check(selector(span.borrow()))?)
}
}
_ => Err(BadSelector0::Value),
}
}
fn parse_selectors_str(v: &Value) -> Result<Selectors, BadSelector0> {
match v {
Value::Literal(s) => {
if s.value().is_empty() {
Ok(Selectors::root())
} else {
let span = input_span(s.value());
Ok(ParseError::check(selectors(span.borrow()))?)
}
}
_ => Err(BadSelector0::Value),
}
}
fn push_descendant(to: &mut Vec<SelectorPart>, from: &mut Selector) {
if !to.is_empty() {
to.push(SelectorPart::Descendant);
}
to.append(&mut from.0);
}
/// A single css selector.
///
/// A selector does not contain `,`. If it does, it is a `Selectors`,
/// where each of the parts separated by the comma is a `Selector`.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub struct Selector(pub(crate) Vec<SelectorPart>);
impl Selector {
/// Get the root (empty) selector.
pub fn root() -> Self {
Self(vec![])
}
fn join(&self, other: &Self, alt_context: &Self) -> Self {
if other.has_backref() {
let mut result = Vec::new();
let context = if self.0.is_empty() { alt_context } else { self };
for p in &other.0 {
result.extend(p.clone_in(context));
}
Self(result)
} else {
let mut result = self.0.clone();
if !result.is_empty()
&& !other.0.first().map_or(false, SelectorPart::is_operator)
{
result.push(SelectorPart::Descendant);
}
result.extend(other.0.iter().cloned());
Self(result)
}
}
/// Validate that this selector is ok to use in css.
///
/// `Selectors` can contain backref (`&`), but those must be
/// resolved before using the `Selectors` in css.
pub fn css_ok(self) -> Result<Self, BadSelector> {
if self.has_backref() {
let slf = self.to_string();
Err(BadSelector::Backref(input_span(slf)))
} else {
Ok(self)
}
}
fn has_backref(&self) -> bool {
self.0.iter().any(SelectorPart::has_backref)
}
/// Return this selector without placeholders.
///
/// For most plain selectors, this returns Some(clone of self).
/// For placeholder selectors, it returns None.
/// For some selectors containing e.g. `p:matches(%a,.foo)` it
/// returns a modified selector (in that case, `p:matches(.foo)`).
fn no_placeholder(&self) -> Option<Self> {
let v = self
.0
.iter()
.map(SelectorPart::no_placeholder)
.collect::<Option<Vec<_>>>()?;
let mut v2 = Vec::with_capacity(v.len());
let mut has_sel = false;
for part in v {
if has_sel && part.is_wildcard() {
continue;
}
has_sel = !part.is_operator();
v2.push(part);
}
let result = Self(v2);
if result.has_trailing_combinator() || result.has_double_combinator()
{
None
} else {
Some(result)
}
}
fn has_leading_combinator(&self) -> bool {
matches!(self.0.first(), Some(SelectorPart::RelOp(_)))
}
/// Return true if this selector ends with a combinator
pub fn has_trailing_combinator(&self) -> bool {
matches!(self.0.last(), Some(SelectorPart::RelOp(_)))
}
fn has_double_combinator(&self) -> bool {
self.0.windows(2).any(|w| {
matches!(w, [SelectorPart::RelOp(_), SelectorPart::RelOp(_)])
})
}
}
impl TryFrom<Value> for Selector {
type Error = BadSelector;
fn try_from(value: Value) -> Result<Self, Self::Error> {
value_to_selector(&value).map_err(move |e| e.ctx(value))
}
}
// Internal, the api is try_into.
fn value_to_selector(v: &Value) -> Result<Selector, BadSelector0> {
match v {
Value::List(list, None | Some(ListSeparator::Space), _) => {
list_to_selector(list)
}
Value::Literal(s) => {
if s.value().is_empty() {
Ok(Selector::root())
} else {
let span = input_span(s.value());
Ok(ParseError::check(selector(span.borrow()))?)
}
}
_ => Err(BadSelector0::Value),
}
}
fn list_to_selector(list: &[Value]) -> Result<Selector, BadSelector0> {
list.iter()
.try_fold(vec![], |mut a, v| {
let parts = value_to_selector_parts(v)?;
if !parts.first().map_or(true, SelectorPart::is_operator)
&& !a.last().map_or(true, SelectorPart::is_operator)
{
a.push(SelectorPart::Descendant);
}
a.extend(parts);
Ok(a)
})
.map(Selector)
}
/// A selector consist of a sequence of these parts.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub enum SelectorPart {
/// A simple selector, eg a class, id or element name.
Simple(String),
/// The empty relational operator.
///
/// The thing after this is a descendant of the thing before this.
Descendant,
/// A relational operator; `>`, `+`, `~`.
RelOp(u8),
/// An attribute selector
Attribute {
/// The attribute name
// TODO: Why not a raw String?
name: CssString,
/// An operator
op: String,
/// A value to match.
val: CssString,
/// Optional modifier.
modifier: Option<char>,
},
/// A css3 pseudo-element (::foo)
PseudoElement {
/// The name of the pseudo-element
name: CssString,
/// Arguments to the pseudo-element
arg: Option<Selectors>,
},
/// A pseudo-class or a css2 pseudo-element (:foo)
Pseudo {
/// The name of the pseudo-class
name: CssString,
/// Arguments to the pseudo-class
arg: Option<Selectors>,
},
/// A sass backref (`&`), to be replaced with outer selector.
BackRef,
}
impl SelectorPart {
pub(crate) fn is_operator(&self) -> bool {
match *self {
Self::Descendant | Self::RelOp(_) => true,
Self::Simple(_)
| Self::Attribute { .. }
| Self::PseudoElement { .. }
| Self::Pseudo { .. }
| Self::BackRef => false,
}
}
pub(crate) fn is_wildcard(&self) -> bool {
if let Self::Simple(s) = self {
s == "*"
} else {
false
}
}
fn has_backref(&self) -> bool {
match *self {
Self::Descendant
| Self::RelOp(_)
| Self::Simple(_)
| Self::Attribute { .. } => false,
Self::BackRef => true,
Self::PseudoElement { ref arg, .. }
| Self::Pseudo { ref arg, .. } => arg
.as_ref()
.map_or(false, |a| a.s.iter().any(Selector::has_backref)),
}
}
/// Return this selectorpart without placeholders.
///
/// For most parts, this returns either Some(clone of self) or None if
/// it was a placeholder selector, but some pseudoselectors are
/// converted to a version without the placeholder parts.
fn no_placeholder(&self) -> Option<Self> {
match self {
Self::Simple(s) => {
if !s.starts_with('%') {
Some(Self::Simple(s.clone()))
} else {
None
}
}
Self::Pseudo { name, arg } => match name.value() {
"is" => arg
.as_ref()
.and_then(Selectors::no_placeholder)
.and_then(Selectors::no_leading_combinator)
.map(|arg| Self::Pseudo {
name: name.clone(),
arg: Some(arg),
}),
"matches" | "any" | "where" | "has" => arg
.as_ref()
.and_then(Selectors::no_placeholder)
.map(|arg| Self::Pseudo {
name: name.clone(),
arg: Some(arg),
}),
"not" => {
if let Some(arg) =
arg.as_ref().and_then(Selectors::no_placeholder)
{
Some(Self::Pseudo {
name: name.clone(),
arg: Some(arg),
})
} else {
Some(Self::Simple("*".into()))
}
}
_ => Some(Self::Pseudo {
name: name.clone(),
arg: arg.clone(),
}),
},
x => Some(x.clone()),
}
}
fn clone_in(&self, context: &Selector) -> Vec<Self> {
match self {
s @ (Self::Descendant
| Self::RelOp(_)
| Self::Simple(_)
| Self::Attribute { .. }) => vec![s.clone()],
Self::BackRef => context.0.clone(),
Self::PseudoElement { name, arg } => {
vec![Self::PseudoElement {
name: name.clone(),
arg: arg.as_ref().map(|a| {
a.inside(&SelectorCtx::root_with_backref(
context.clone(),
))
}),
}]
}
Self::Pseudo { name, arg } => {
vec![Self::Pseudo {
name: name.clone(),
arg: arg.as_ref().map(|a| {
a.inside(&SelectorCtx::root_with_backref(
context.clone(),
))
}),
}]
}
}
}
}
fn value_to_selector_parts(
v: &Value,
) -> Result<Vec<SelectorPart>, BadSelector0> {
match v {
Value::Literal(s) => Ok(ParseError::check(selector_parts(
input_span(s.value()).borrow(),
))?),
_ => Err(BadSelector0::Value),
}
}
// TODO: This shoule probably be on Formatted<Selectors> instead.
impl fmt::Display for Selectors {
fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
if let Some((first, rest)) = self.s.split_first() {
first.fmt(out)?;
let separator = if out.alternate() { "," } else { ", " };
for item in rest {
out.write_str(separator)?;
item.fmt(out)?;
}
}
Ok(())
}
}
impl fmt::Display for Selector {
fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
// Note: There should be smarter whitespace-handling here, avoiding
// the need to clean up afterwards.
let mut buf = vec![];
for p in &self.0 {
if out.alternate() {
write!(&mut buf, "{p:#}").map_err(|_| fmt::Error)?;
} else {
write!(&mut buf, "{p}").map_err(|_| fmt::Error)?;
}
}
if buf.ends_with(b"> ") {
buf.pop();
}
while buf.first() == Some(&b' ') {
buf.remove(0);
}
let buf = String::from_utf8(buf).map_err(|_| fmt::Error)?;
out.write_str(&buf.replace(" ", " "))
}
}
impl fmt::Display for SelectorPart {
fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
match *self {
Self::Simple(ref s) => write!(out, "{s}"),
Self::Descendant => write!(out, " "),
Self::RelOp(ref c) => {
if out.alternate() && *c != b'~' {
write!(out, "{}", *c as char)
} else {
write!(out, " {} ", *c as char)
}
}
Self::Attribute {
ref name,
ref op,
ref val,
ref modifier,
} => write!(
out,
"[{name}{op}{val}{}]",
modifier.map(|m| format!(" {m}")).unwrap_or_default()
),
Self::PseudoElement { ref name, ref arg } => {
write!(out, "::{name}")?;
if let Some(ref arg) = *arg {
if out.alternate() {
write!(out, "({arg:#})")?;
} else {
write!(out, "({arg})")?;
}
}
Ok(())
}
Self::Pseudo { ref name, ref arg } => {
let name = name.to_string();
if let Some(ref arg) = *arg {
// It seems some pseudo-classes should always have
// their arg in compact form. Maybe we need more
// hard-coded names here, or maybe the condition
// should be on the argument rather than the name?
if out.alternate() || name == "nth-of-type" {
write!(out, ":{name}({arg:#})",)
} else if name == "nth-child" {
let arg = format!("{arg:#}");
write!(out, ":{name}({})", arg.replace(',', ", "))
} else {
write!(out, ":{name}({arg})")
}
} else {
write!(out, ":{name}")
}
}
Self::BackRef => write!(out, "&"),
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn root_join() {
let s = Selector(vec![SelectorPart::Simple("foo".into())]);
assert_eq!(Selector::root().join(&s, &Selector::root()), s)
}
#[test]
fn simple_join() {
let s = Selector(vec![SelectorPart::Simple("foo".into())]).join(
&Selector(vec![SelectorPart::Simple(".bar".into())]),
&Selector::root(),
);
assert_eq!(format!("{}", s), "foo .bar")
}
#[test]
fn backref_join() {
let s = Selector(vec![SelectorPart::Simple("foo".into())]).join(
&Selector(vec![
SelectorPart::BackRef,
SelectorPart::Simple(".bar".into()),
]),
&Selector::root(),
);
assert_eq!(format!("{}", s), "foo.bar")
}
}
enum BadSelector0 {
Value,
Parse(ParseError),
}
impl BadSelector0 {
fn ctx(self, v: Value) -> BadSelector {
match self {
Self::Value => BadSelector::Value(v),
Self::Parse(err) => BadSelector::Parse(err),
}
}
}
impl From<ParseError> for BadSelector0 {
fn from(e: ParseError) -> Self {
Self::Parse(e)
}
}
/// The error when a [Value] cannot be converted to a [Selectors] or [Selector].
#[derive(Debug)]
pub enum BadSelector {
/// The value was not the expected type of list or string.
Value(Value),
/// There was an error parsing a string value.
Parse(ParseError),
/// A backref (`&`) were present but not allowed there.
Backref(SourcePos),
/// Cant append extenstion to base.
Append(Selector, Selector),
}
impl fmt::Display for BadSelector {
fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Value(v) => out.write_str(&is_not(
v,
"a valid selector: it must be a string,\
\na list of strings, or a list of lists of strings",
)),
Self::Parse(e) => e.fmt(out),
Self::Backref(pos) => {
writeln!(out, "Parent selectors aren\'t allowed here.")?;
pos.show(out)
}
Self::Append(e, b) => {
write!(out, "Can't append {e} to {b}.")
}
}
}
}
impl From<ParseError> for BadSelector {
fn from(e: ParseError) -> Self {
Self::Parse(e)
}
}