tildes-parser/source/from_str.rs

23 lines
419 B
Rust
Raw Normal View History

//! Implements [`FromStr`] for parser structs.
use std::str::FromStr;
use {duplicate::duplicate_item, scraper::Html};
2023-06-21 09:59:38 +00:00
use crate::{Group, GroupList, ParseError, Topic};
#[duplicate_item(
_Struct;
[Group];
[GroupList];
2023-06-21 09:59:38 +00:00
[Topic];
)]
impl FromStr for _Struct {
type Err = ParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let html = Html::parse_document(s);
2022-10-17 10:47:35 +00:00
Self::from_html(&html)
}
}