Enum noodles_gff::record::attributes::field::value::Value
source · pub enum Value {
String(String),
Array(Vec<String>),
}
Expand description
A GFF record attribute field value.
Variants§
Implementations§
source§impl Value
impl Value
sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Returns the value as a string, if the value is a string.
§Examples
use noodles_gff::record::attributes::field::Value;
let value = Value::from("ndls");
assert_eq!(value.as_string(), Some("ndls"));
let value = Value::from(vec![String::from("ndls0"), String::from("ndls1")]);
assert!(value.as_string().is_none());
sourcepub fn as_array(&self) -> Option<&[String]>
pub fn as_array(&self) -> Option<&[String]>
Returns the value as an array, if the value is an array.
§Examples
use noodles_gff::record::attributes::field::Value;
let raw_values = vec![String::from("ndls0"), String::from("ndls1")];
let value = Value::from(raw_values.clone());
assert_eq!(value.as_array(), Some(&raw_values[..]));
let value = Value::from("ndls");
assert!(value.as_array().is_none());
sourcepub fn iter(&self) -> Box<dyn Iterator<Item = &String> + '_>
pub fn iter(&self) -> Box<dyn Iterator<Item = &String> + '_>
An iterator over values.
§Examples
use noodles_gff::record::attributes::field::Value;
let value = Value::from("ndls");
let mut iter = value.iter();
assert_eq!(iter.next(), Some(&String::from("ndls")));
assert!(iter.next().is_none());
let value = Value::from(vec![String::from("ndls0"), String::from("ndls1")]);
let mut iter = value.iter();
assert_eq!(iter.next(), Some(&String::from("ndls0")));
assert_eq!(iter.next(), Some(&String::from("ndls1")));
assert!(iter.next().is_none());
Trait Implementations§
source§impl Extend<String> for Value
impl Extend<String> for Value
source§fn extend<T: IntoIterator<Item = String>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = String>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
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)
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<'a> IntoIterator for &'a Value
impl<'a> IntoIterator for &'a Value
source§impl PartialEq for Value
impl PartialEq for Value
impl Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.