I tried this code:
pub fn transliterate(mut origin: String) -> String {
let counter: usize = origin.chars().count();
let mut j: usize = 0;
let mut i: usize = 0;
let origin_vec: Vec<char> = origin.chars().collect();
let mut origin_mutated: Vec<char>;
if j <= counter {
while j <= counter {
match origin_vec[j] {
'А' => {
origin_mutated[i] = 'A';
i += 1;
j += 1;
}
// snip
'Я' => {
origin_mutated[i] = 'Y';
i += 1;
j += 1;
origin_mutated[i] = 'a';
i += 1;
}
_ => {
j += 1;
}
}
}
} else if j > counter {
origin_mutated[i] = '\n';
} else {
origin = origin_mutated.into_iter().collect();
}
//origin = origin_mutated.into_iter().collect();
(origin)
}
I expected to see this happen: the possibly-uninitialized error would report the textually first usage of origin_mutated
error[E0381]: borrow of possibly-uninitialized variable: `origin_mutated`
--> src/lib.rs:11:21
|
11 | origin_mutated[i] = 'A';
| ^^^^^^^^^^^^^^ use of possibly-uninitialized `origin_mutated`
Instead, this happened: the possibly-uninitialized error reports the textually last usage of origin_mutated
error[E0381]: borrow of possibly-uninitialized variable: `origin_mutated`
--> src/lib.rs:188:21
|
188 | origin_mutated[i] = 'Y';
| ^^^^^^^^^^^^^^ use of possibly-uninitialized `origin_mutated`
Originally reported by L0uisc on irlo.
@rustbot modify labels: +A-diagnostics, +D-papercut
I tried this code:
I expected to see this happen: the possibly-uninitialized error would report the textually first usage of
origin_mutatedInstead, this happened: the possibly-uninitialized error reports the textually last usage of
origin_mutatedOriginally reported by L0uisc on irlo.
@rustbot modify labels: +A-diagnostics, +D-papercut