Skip to main content

s_igraph_strvector

Struct s_igraph_strvector 

Source
pub struct s_igraph_strvector { /* private fields */ }

Implementations§

Source§

impl s_igraph_strvector

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 s_igraph_strvector

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 Debug for s_igraph_strvector

Source§

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

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

impl From<&s_igraph_strvector> for Vec<String>

Source§

fn from(sv: &igraph_strvector_t) -> Self

Converts to this type from the input type.
Source§

impl From<s_igraph_strvector> for Vec<String>

Source§

fn from(sv: igraph_strvector_t) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.