Skip to main content

seq_get

Function seq_get 

Source
pub fn seq_get<T>(seq: &[T], index: isize) -> Option<&T>
Expand description

Returns the value in seq at position index, or None if index is out of bounds.

Supports negative indexing like Python (e.g., -1 for last element).

ยงExample

use polyglot_sql::helper::seq_get;

let v = vec![1, 2, 3];
assert_eq!(seq_get(&v, 0), Some(&1));
assert_eq!(seq_get(&v, -1), Some(&3));
assert_eq!(seq_get(&v, 10), None);