pub struct List(/* private fields */);Expand description
A lightweight wrapper around a protobuf ListValue.
Implementations§
Source§impl List
impl List
Sourcepub fn get(&self, index: usize) -> Option<&Value>
pub fn get(&self, index: usize) -> Option<&Value>
Returns the value at the given index, or None if the index is out of bounds.
Sourcepub fn iter(
&self,
) -> impl DoubleEndedIterator<Item = &Value> + ExactSizeIterator
pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = &Value> + ExactSizeIterator
Returns an iterator over the values in the list.
§Example
use google_cloud_spanner::value::Value;
let value = Value::from(vec![1.0, 2.0]);
if let Some(list) = value.as_list() {
for element in list.iter() {
println!("{element:?}");
}
}Sourcepub fn into_values(self) -> Vec<Value>
pub fn into_values(self) -> Vec<Value>
Consumes the list and returns its elements as a vector of Values.
§Example
use google_cloud_spanner::value::Value;
let value = Value::from(vec![1i64, 2i64]);
let list = value.into_list().expect("value is a list");
let values = list.into_values();
assert_eq!(values.len(), 2, "extracted list should have 2 elements");
assert_eq!(values[0].as_str(), Some("1"), "first element should be '1'");Trait Implementations§
impl StructuralPartialEq for List
Auto Trait Implementations§
impl Forget for List
impl Freeze for List
impl Move for List
impl RefUnwindSafe for List
impl Send for List
impl Sync for List
impl Unpin for List
impl UnsafeUnpin for List
impl UnwindSafe for List
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request