#[derive(de_hypertext::Deserialize)]
struct MyStruct {
#[de_hypertext(selector = "a")]
field1: String,
}
The derive macro generates the following snippet
document
.select(
&de_hypertext::scraper::Selector::parse("a")
.map_err(|_| {
de_hypertext::DeserializeError::BuildingSelectorFailed {
struct_name: std::any::type_name::<Self>().to_string(),
field: "field1".to_string(),
selector: "a".to_string(),
}
})?,
)
However, this code will only check if the selector is valid at runtime. Since we specify the selectors when writing the code, couldn't we check if the selectors are valid at compile time?
The derive macro generates the following snippet
document .select( &de_hypertext::scraper::Selector::parse("a") .map_err(|_| { de_hypertext::DeserializeError::BuildingSelectorFailed { struct_name: std::any::type_name::<Self>().to_string(), field: "field1".to_string(), selector: "a".to_string(), } })?, )However, this code will only check if the selector is valid at runtime. Since we specify the selectors when writing the code, couldn't we check if the selectors are valid at compile time?