Skip to content

String::replace_range leads to runtime errors while it should not #1249

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

Closed
Anatoly03 opened this issue Mar 22, 2023 · 0 comments
Closed

String::replace_range leads to runtime errors while it should not #1249

Anatoly03 opened this issue Mar 22, 2023 · 0 comments

Comments

@Anatoly03
Copy link

🐛 Bug description

String::replace_range(&mut self) leads to RuntimeError: unreachable

🤔 Expected Behavior

The range should be replaced without assertions

👟 Steps to reproduce/ MRE

use wasm_bindgen::prelude::*;

use super::filter::Filter;

#[wasm_bindgen]
impl Filter {
    pub fn replace(&mut self, content: String) -> String {
        let mut censored = // String Content
        let ranges = ... // Vector of Ranges

        for range in ranges {
            censored.replace_range(range, "*");
        }

        censored
    }
}

🌍 Your environment

Intel Mac
wasm-pack and rustc version:

Screenshot 2023-03-22 at 10 15 12

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

No branches or pull requests

1 participant