rust-cssparser icon indicating copy to clipboard operation
rust-cssparser copied to clipboard

Token usage of CowRcStr and NonNull/Rc<String> makes it non Send

Open jlaffaye opened this issue 2 years ago • 3 comments

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(())
}

jlaffaye avatar Nov 30 '23 16:11 jlaffaye

I wonder if https://docs.rs/fragile/1.0.0/fragile/index.html can help.in the short term?

jdm avatar Dec 01 '23 19:12 jdm

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.

FranklinChen avatar Dec 19 '23 00:12 FranklinChen

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.

emilio avatar Apr 06 '24 17:04 emilio