Skip to content

Commit

Permalink
feat(term): add Annotated::project
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed Apr 13, 2024
1 parent a1646a5 commit ddb1c0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/synd_feed/src/types/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ impl<'a> Category<'a> {
Ok(Self(c.into()))
}

pub fn as_str(&self) -> &str {
self.0.as_ref()
}

pub fn into_inner(self) -> Cow<'a, str> {
self.0
}
Expand Down
20 changes: 20 additions & 0 deletions crates/synd_feed/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ pub struct Annotated<T> {
pub category: Option<Category<'static>>,
}

impl<T> Annotated<T> {
pub fn project<U>(&self, f: impl Fn(&T) -> U) -> Annotated<U> {
Annotated {
feed: f(&self.feed),
requirement: self.requirement,
category: self.category.clone(),
}
}
}

impl<T> Annotated<T> {
pub fn new(feed: T) -> Self {
Self {
feed,
requirement: None,
category: None,
}
}
}

impl FeedMeta {
pub fn r#type(&self) -> &FeedType {
&self.feed_type
Expand Down

0 comments on commit ddb1c0a

Please sign in to comment.