1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Add assert messages and print bad argument values in asserts (#5216)

Enabled the `missing_assert_message` lint

* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Lucas Meurer <lucasmeurer96@gmail.com>
This commit is contained in:
Nicolas
2025-03-25 09:20:29 +01:00
committed by GitHub
parent 903bd81313
commit 58b2ac88c0
35 changed files with 331 additions and 108 deletions

View File

@@ -490,8 +490,15 @@ impl Highlighter {
fn as_byte_range(whole: &str, range: &str) -> std::ops::Range<usize> {
let whole_start = whole.as_ptr() as usize;
let range_start = range.as_ptr() as usize;
assert!(whole_start <= range_start);
assert!(range_start + range.len() <= whole_start + whole.len());
assert!(
whole_start <= range_start,
"range must be within whole, but was {range}"
);
assert!(
range_start + range.len() <= whole_start + whole.len(),
"range_start + range length must be smaller than whole_start + whole length, but was {}",
range_start + range.len()
);
let offset = range_start - whole_start;
offset..(offset + range.len())
}