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

Function char_range_end

crates/common/src/str.rs:367–376  ·  view source on GitHub ↗
(s: &str, n_chars: usize)

Source from the content-addressed store, hash-verified

365
366#[inline]
367pub fn char_range_end(s: &str, n_chars: usize) -> Option<usize> {
368 let i = match n_chars.checked_sub(1) {
369 Some(last_char_index) => {
370 let (index, c) = s.char_indices().nth(last_char_index)?;
371 index + c.len_utf8()
372 }
373 None => 0,
374 };
375 Some(i)
376}
377
378pub fn try_get_codepoints(w: &Wtf8, range: impl RangeBounds<usize>) -> Option<&Wtf8> {
379 let mut chars = w.code_points();

Callers 1

try_get_charsFunction · 0.85

Calls 1

SomeClass · 0.50

Tested by

no test coverage detected