[−]Struct fluence_app_service::vec1::Vec1
Vec1<T>
represents a non-empty Vec<T>
. It derefs to Vec<T>
directly.
Implementations
impl<T> Vec1<T> where
T: Debug,
T: Debug,
pub fn new(items: Vec<T>) -> Result<Vec1<T>, EmptyVec>
Creates a new non-empty vector, based on an inner Vec<T>
. If
the inner vector is empty, a EmptyVec
error is returned.
pub fn into_vec(self) -> Vec<T>ⓘ
Converts this Vec1 into Vec
Methods from Deref<Target = Vec<T>>
pub fn capacity(&self) -> usize
1.0.0[src]
Returns the number of elements the vector can hold without reallocating.
Examples
let vec: Vec<i32> = Vec::with_capacity(10); assert_eq!(vec.capacity(), 10);
pub fn as_slice(&self) -> &[T]
1.7.0[src]
Extracts a slice containing the entire vector.
Equivalent to &s[..]
.
Examples
use std::io::{self, Write}; let buffer = vec![1, 2, 3, 5, 8]; io::sink().write(buffer.as_slice()).unwrap();
pub fn as_ptr(&self) -> *const T
1.37.0[src]
Returns a raw pointer to the vector's buffer.
The caller must ensure that the vector outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the vector may cause its buffer to be reallocated, which would also make any pointers to it invalid.
The caller must also ensure that the memory the pointer (non-transitively) points to
is never written to (except inside an UnsafeCell
) using this pointer or any pointer
derived from it. If you need to mutate the contents of the slice, use as_mut_ptr
.
Examples
let x = vec![1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(*x_ptr.add(i), 1 << i); } }
pub fn len(&self) -> usize
1.0.0[src]
Returns the number of elements in the vector, also referred to as its 'length'.
Examples
let a = vec![1, 2, 3]; assert_eq!(a.len(), 3);
pub fn is_empty(&self) -> bool
1.0.0[src]
Returns true
if the vector contains no elements.
Examples
let mut v = Vec::new(); assert!(v.is_empty()); v.push(1); assert!(!v.is_empty());
Trait Implementations
impl<T> Clone for Vec1<T> where
T: Clone + Debug,
T: Clone + Debug,
pub fn clone(&self) -> Vec1<T>
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Debug for Vec1<T> where
T: Debug,
T: Debug,
impl<T> Default for Vec1<T> where
T: Default + Debug,
T: Default + Debug,
impl<T> Deref for Vec1<T> where
T: Debug,
T: Debug,
type Target = Vec<T>
The resulting type after dereferencing.
pub fn deref(&self) -> &<Vec1<T> as Deref>::Target
impl<'de, T> Deserialize<'de> for Vec1<T> where
T: Debug + Deserialize<'de>,
T: Debug + Deserialize<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Vec1<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
__deserializer: __D
) -> Result<Vec1<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl<T> Eq for Vec1<T> where
T: Eq + Debug,
T: Eq + Debug,
impl<T> Hash for Vec1<T> where
T: Hash + Debug,
T: Hash + Debug,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> PartialEq<Vec1<T>> for Vec1<T> where
T: PartialEq<T> + Debug,
T: PartialEq<T> + Debug,
impl<T> Serialize for Vec1<T> where
T: Debug + Serialize,
T: Debug + Serialize,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
impl<T> StructuralEq for Vec1<T> where
T: Debug,
T: Debug,
impl<T> StructuralPartialEq for Vec1<T> where
T: Debug,
T: Debug,
Auto Trait Implementations
impl<T> RefUnwindSafe for Vec1<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Vec1<T> where
T: Send,
T: Send,
impl<T> Sync for Vec1<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vec1<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vec1<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]
T: Serialize + ?Sized,
pub fn erased_serialize(
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
[src]
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,