Skip to main content

igraph_strvector_t

Type Alias igraph_strvector_t 

Source
pub type igraph_strvector_t = s_igraph_strvector;

Aliased Type§

pub struct igraph_strvector_t { /* private fields */ }

Implementations§

Source§

impl igraph_strvector_t

Source

pub fn new() -> Self

Creates an empty string vector (igraph_strvector_init).

Source

pub fn len(&self) -> usize

Number of strings (igraph_strvector_size).

Source

pub fn is_empty(&self) -> bool

Whether there are no strings.

Source

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).

Source

pub fn get_cstr(&self, index: usize) -> Option<&CStr>

The raw C string at index, if any, borrowed from the vector (igraph_strvector_get).

Source

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

pub fn iter(&self) -> impl Iterator<Item = String> + '_

Iterates over the strings (lossily converted to UTF-8).

Source

pub fn to_vec(&self) -> Vec<String>

Copies the strings into a Vec<String>.

Source§

impl igraph_strvector_t

Source

pub fn with_len(len: usize) -> Self

Creates a vector of len empty strings (igraph_strvector_init).

Source

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.

Source

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.

Source

pub fn pop(&mut self) -> Option<String>

Removes and returns the last string, if any.

Source

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.

Source

pub fn extend_from(&mut self, other: &Self)

Appends copies of all the strings of other (igraph_strvector_append).

Source

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).

Source

pub fn resize(&mut self, len: usize)

Resizes to len strings: extra strings are dropped, new ones are empty (igraph_strvector_resize).

Source

pub fn truncate(&mut self, len: usize)

Keeps only the first len strings (no-op if already shorter).

Source

pub fn clear(&mut self)

Removes all strings (igraph_strvector_clear).

Source

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.

Source

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.

Source

pub fn capacity(&self) -> usize

Number of strings that fit without reallocating (igraph_strvector_capacity).

Source

pub fn reserve(&mut self, capacity: usize)

Reserves room for at least capacity strings in total (igraph_strvector_reserve).

Source

pub fn shrink_to_fit(&mut self)

Frees the unused storage (igraph_strvector_resize_min).

Source

pub fn contains(&self, value: &str) -> bool

Whether some string equals value.

Source

pub fn position(&self, value: &str) -> Option<usize>

Position of the first string equal to value, if any.

Trait Implementations§

Source§

impl Clone for igraph_strvector_t

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for igraph_strvector_t

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for igraph_strvector_t

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for igraph_strvector_t

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<S: AsRef<str>> Extend<S> for igraph_strvector_t

Source§

fn extend<I: IntoIterator<Item = S>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<S: AsRef<str>> From<&[S]> for igraph_strvector_t

Source§

fn from(items: &[S]) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<String>> for igraph_strvector_t

Source§

fn from(items: Vec<String>) -> Self

Converts to this type from the input type.
Source§

impl<S: AsRef<str>> FromIterator<S> for igraph_strvector_t

Source§

fn from_iter<I: IntoIterator<Item = S>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Index<usize> for igraph_strvector_t

Source§

fn index(&self, index: usize) -> &str

The string at index.

§Panics

If index is out of bounds or the string is not valid UTF-8.

Source§

type Output = str

The returned type after indexing.
Source§

impl<'a> IntoIterator for &'a igraph_strvector_t

Source§

type Item = String

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = String> + 'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for igraph_strvector_t

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[&str]> for igraph_strvector_t

Source§

fn eq(&self, other: &[&str]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Send for igraph_strvector_t

Source§

impl Sync for igraph_strvector_t