pub type igraph_strvector_t = s_igraph_strvector;Aliased Type§
pub struct igraph_strvector_t { /* private fields */ }Implementations§
Source§impl igraph_strvector_t
impl igraph_strvector_t
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty string vector
(igraph_strvector_init).
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of strings
(igraph_strvector_size).
Sourcepub fn get(&self, index: usize) -> Option<&str>
pub fn get(&self, index: usize) -> Option<&str>
The string at index, or None if index is out of bounds or the
string is not valid UTF-8 (use get_cstr, or the
lossy iter and to_vec, for such
strings) (igraph_strvector_get).
Sourcepub fn get_cstr(&self, index: usize) -> Option<&CStr>
pub fn get_cstr(&self, index: usize) -> Option<&CStr>
The raw C string at index, if any, borrowed from the vector
(igraph_strvector_get).
Sourcepub fn push(&mut self, value: &str)
pub fn push(&mut self, value: &str)
Appends a copy of value (interior NUL bytes truncate it when read
back) (igraph_strvector_push_back_len).
Source§impl igraph_strvector_t
impl igraph_strvector_t
Sourcepub fn with_len(len: usize) -> Self
pub fn with_len(len: usize) -> Self
Creates a vector of len empty strings
(igraph_strvector_init).
Sourcepub fn set(&mut self, index: usize, value: &str) -> Result<()>
pub fn set(&mut self, index: usize, value: &str) -> Result<()>
Replaces the string at index with a copy of value
(igraph_strvector_set_len).
use igraph::prelude::*;
let mut names = StrVector::with_len(3);
names.set(1, "hub").unwrap();
assert_eq!(names.to_vec(), vec!["", "hub", ""]);
assert_eq!(&names[1], "hub");
assert!(names.set(3, "nope").is_err());§Errors
ErrorKind::InvalidValue if
index is out of bounds.
Sourcepub fn remove(&mut self, index: usize) -> String
pub fn remove(&mut self, index: usize) -> String
Removes the string at index and returns it (lossily converted to
UTF-8) (igraph_strvector_remove).
§Panics
If index is out of bounds.
Sourcepub fn remove_section(&mut self, range: Range<usize>)
pub fn remove_section(&mut self, range: Range<usize>)
Removes the strings in range
(igraph_strvector_remove_section).
§Panics
If the range goes past the end.
Sourcepub fn extend_from(&mut self, other: &Self)
pub fn extend_from(&mut self, other: &Self)
Appends copies of all the strings of other
(igraph_strvector_append).
Sourcepub fn append(&mut self, other: &mut Self)
pub fn append(&mut self, other: &mut Self)
Moves all the strings of other to the end of self, leaving
other empty, without copying them, like Vec::append
(igraph_strvector_merge).
Sourcepub fn resize(&mut self, len: usize)
pub fn resize(&mut self, len: usize)
Resizes to len strings: extra strings are dropped, new ones are
empty (igraph_strvector_resize).
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Keeps only the first len strings (no-op if already shorter).
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all strings
(igraph_strvector_clear).
Sourcepub fn select(&self, index: &[igraph_int_t]) -> Result<Self>
pub fn select(&self, index: &[igraph_int_t]) -> Result<Self>
A new vector with the strings at the given positions (repetitions
allowed) (igraph_strvector_index, undocumented in igraph_strvector.h).
§Errors
ErrorKind::InvalidValue if
some position is out of bounds.
Sourcepub fn swap(&mut self, i: usize, j: usize)
pub fn swap(&mut self, i: usize, j: usize)
Swaps the strings at i and j
(igraph_strvector_swap_elements).
§Panics
If an index is out of bounds.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Number of strings that fit without reallocating
(igraph_strvector_capacity).
Sourcepub fn reserve(&mut self, capacity: usize)
pub fn reserve(&mut self, capacity: usize)
Reserves room for at least capacity strings in total
(igraph_strvector_reserve).
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Frees the unused storage
(igraph_strvector_resize_min).
Trait Implementations§
Source§impl Clone for igraph_strvector_t
impl Clone for igraph_strvector_t
Source§impl Default for igraph_strvector_t
impl Default for igraph_strvector_t
Source§impl Display for igraph_strvector_t
impl Display for igraph_strvector_t
Source§impl Drop for igraph_strvector_t
impl Drop for igraph_strvector_t
Source§impl<S: AsRef<str>> Extend<S> for igraph_strvector_t
impl<S: AsRef<str>> Extend<S> for igraph_strvector_t
Source§fn extend<I: IntoIterator<Item = S>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = S>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)