Token usage of CowRcStr and NonNull/Rc<String> makes it non Send
And it is required by anyhow in async functions.
To reproduce, try to compile this code
use scraper::Selector;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let selector = Selector::parse("#top")?;
Ok(())
}
I wonder if https://docs.rs/fragile/1.0.0/fragile/index.html can help.in the short term?
I just noticed this too today in a project of mine, and as a quick hack (since I don't care that much about the error case right now), used a workaround for now
let row_selector = Selector::parse("tr.am-grid-row").map_err(|k| anyhow!(k.to_string()))?;
but look forward to a better solution.
So the issue is that errors have CowRcStrs, right? I don't think we really want to turn such thing into something that's Send, it's very intentional to avoid performance overhead.
Is there a way of telling anyhow or such to turn the error into Send-able error easily? If so we could put such code behind a feature gate without much trouble. But yeah making Token in particular use atomic operations when not needed is probably a no-go.