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

Fix lev_distance in libcollections/str.rs #17738

Merged
merged 1 commit into from
Oct 4, 2014
Merged

Fix lev_distance in libcollections/str.rs #17738

merged 1 commit into from
Oct 4, 2014

Conversation

tilpner
Copy link
Contributor

@tilpner tilpner commented Oct 3, 2014

There is an issue with lev_distance, where

fn main() {
    println!("{}", "\x80".lev_distance("\x80"))
}

prints 2.

This is due to using the byte length instead of the char length.

@huonw
Copy link
Member

huonw commented Oct 3, 2014

Could you add a test for this?

@tilpner
Copy link
Contributor Author

tilpner commented Oct 4, 2014

@huonw Added a test yesterday.

bors added a commit that referenced this pull request Oct 4, 2014
There is an issue with lev_distance, where
```
fn main() {
    println!("{}", "\x80".lev_distance("\x80"))
}
```
prints `2`.

This is due to using the byte length instead of the char length.
@bors bors closed this Oct 4, 2014
@bors bors merged commit 3aea7f1 into rust-lang:master Oct 4, 2014
if tlen == 0 { return slen; }

let mut dcol = Vec::from_fn(tlen + 1, |x| x);
let mut dcol = Vec::from_fn(t.len() + 1, |x| x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dcol is too long, should be just .char_len() + 1. The difference is often small though.

RalfJung pushed a commit to RalfJung/rust that referenced this pull request Aug 1, 2024
fix: Apply `IndexMut` obligations for non-assigning mutable index usages

Fixes rust-lang#17738

Currently, we are pushing `IndexMut` obligations only for assign usages;
https://github.com/rust-lang/rust-analyzer/blob/f982f3fa2c23570c10108e83c1ecc392ea411866/crates/hir-ty/src/infer/expr.rs#L809-L817
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

Successfully merging this pull request may close these issues.

4 participants