Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jlaffaye opened this issue Nov 30, 2023 · 3 comments
Open

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

jlaffaye opened this issue Nov 30, 2023 · 3 comments

Comments

@jlaffaye
Copy link

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 jlaffaye changed the title SelectorErrorKind usage of NonNull/Rc<String> makes it non Send Token usage of CowRcStr and NonNull/Rc<String> makes it non Send Nov 30, 2023
@jdm
Copy link
Member

jdm commented Dec 1, 2023

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

@FranklinChen
Copy link

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.

@emilio
Copy link
Member

emilio commented Apr 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants