Skip to main content

cursor_position

Function cursor_position 

Source
pub(crate) fn cursor_position<T>(cursor: &Cursor<T>) -> usize
Expand description

The position of a Cursor, as an index into the buffer it wraps.

Cursor stores the position as a u64 and lets it be set anywhere, so on a target where usize is narrower it can name an offset no buffer can hold. Saturating leaves such a position out of range, where the bounds checks below reject it; casting would wrap it around into a valid-looking offset and quietly read or write the wrong part of the buffer.