MCPcopy Index your code
hub / github.com/RustPython/RustPython / substitution_cost

Function substitution_cost

crates/common/src/str.rs:474–488  ·  view source on GitHub ↗
(mut a: u8, mut b: u8)

Source from the content-addressed store, hash-verified

472 const MAX_STRING_SIZE: usize = 40;
473
474 const fn substitution_cost(mut a: u8, mut b: u8) -> usize {
475 if (a & 31) != (b & 31) {
476 return MOVE_COST;
477 }
478 if a == b {
479 return 0;
480 }
481 if a.is_ascii_uppercase() {
482 a += b'a' - b'A';
483 }
484 if b.is_ascii_uppercase() {
485 b += b'a' - b'A';
486 }
487 if a == b { CASE_COST } else { MOVE_COST }
488 }
489
490 pub fn levenshtein_distance(a: &[u8], b: &[u8], max_cost: usize) -> usize {
491 if a == b {

Callers 1

levenshtein_distanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected