use std::fmt::{Display, Formatter};
use super::selector::Selector;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Segment {
Child(ChildSegment),
Descendant(DescendantSegment),
}
impl Display for Segment {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Segment::Child(child_segment) => write!(f, "{}", child_segment),
Segment::Descendant(descendant_segment) => write!(f, "{}", descendant_segment),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ChildSegment {
selectors: Vec<Selector>,
}
impl ChildSegment {
pub fn new(selectors: Vec<Selector>) -> ChildSegment {
ChildSegment { selectors }
}
pub fn selectors(&self) -> &[Selector] {
&self.selectors
}
}
impl Display for ChildSegment {
fn fmt(&self, _f: &mut Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DescendantSegment {
selectors: Vec<Selector>,
}
impl DescendantSegment {
pub fn new(selectors: Vec<Selector>) -> DescendantSegment {
DescendantSegment { selectors }
}
pub fn selectors(&self) -> &[Selector] {
&self.selectors
}
}
impl Display for DescendantSegment {
fn fmt(&self, _f: &mut Formatter<'_>) -> std::fmt::Result {
todo!()
}
}