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
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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.