std::vecVec utility functions.
Pure Hew implementations for common vector operations. These replace the equivalent Rust FFI functions for simple linear scans.
index_of_i32Return Some of the index of val in a Vec<i32>, or None if not found.
index_of_i64Return Some of the index of val in a Vec<i64>, or None if not found.
index_of_f64Return Some of the index of the first occurrence of val in v, or None if not found.
Uses exact equality; NaN will never match.
import std.vec;
fn main() {
var v: Vec<f64> = Vec.new();
v.push(1.5);
v.push(2.5);
match vec.index_of_f64(v, 2.5) {
.Some(i) => println(i), // 1
.None => println("not found"),
}
match vec.index_of_f64(v, 9.9) {
.Some(i) => println(i),
.None => println("not found"), // not found
}
}
index_of_strReturn Some of the index of the first occurrence of val in v, or None if not found.
import std.vec;
fn main() {
var v: Vec<string> = Vec.new();
v.push("a");
v.push("b");
match vec.index_of_str(v, "b") {
.Some(i) => println(i), // 1
.None => println("not found"),
}
match vec.index_of_str(v, "z") {
.Some(i) => println(i),
.None => println("not found"), // not found
}
}
first_i64Return Some of the first element of a Vec<i64>, or None if empty.
first_f64Return Some of the first element of v, or None if v is empty.
first_strReturn Some of the first element of v, or None if v is empty.
last_i64Return Some of the last element of a Vec<i64>, or None if empty.
last_f64Return Some of the last element of v, or None if v is empty.
last_strReturn Some of the last element of v, or None if v is empty.
min_i32Return Some of the smallest element in a Vec<i32>, or None if empty.
min_i64Return Some of the smallest element in a Vec<i64>, or None if empty.
min_f64Return Some of the smallest element in v, or None if v is empty.
NaN propagates: if any element is NaN the result is unspecified.
max_i32Return Some of the largest element in a Vec<i32>, or None if empty.
max_i64Return Some of the largest element in a Vec<i64>, or None if empty.
max_f64Return Some of the largest element in v, or None if v is empty.
NaN propagates: if any element is NaN the result is unspecified.