Rename Vec::as_slice to Vector::as_slice
MODIFY
src/manual/core/vector.rs
src/manual/core/vector.rs
@@ -197,7 +197,7 @@ impl<T: VectorElement> Vector<T> where Self: VectorExtern<T> {
VectorRefIterator::new(self)
}
- pub fn to_slice(&self) -> &[T] where Self: VectorExternCopyNonBool<T> {
+ pub fn as_slice(&self) -> &[T] where Self: VectorExternCopyNonBool<T> {
unsafe {
::std::slice::from_raw_parts(self.extern_data(), self.len())
}

MODIFY
src/manual/core/vector/vector_extern.rs
src/manual/core/vector/vector_extern.rs
@@ -157,7 +157,7 @@ macro_rules! vector_copy_non_bool {
impl $crate::manual::core::VectorElement for $type where $crate::manual::core::Vector<$type>: $crate::manual::core::VectorExtern<$type> {
#[inline(always)]
fn convert_to_vec(v: &$crate::manual::core::Vector<$type>) -> std::vec::Vec<$type> {
- v.to_slice().to_vec()
+ v.as_slice().to_vec()
}
}

MODIFY
tests/vector.rs
tests/vector.rs
@@ -413,17 +413,17 @@ fn iter() -> Result<()> {
fn to_slice() -> Result<()> {
{
let vec = VectorOfu8::from_iter(vec![1, 2, 3, 4, 5]);
- assert_eq!(vec.to_slice(), &[1, 2, 3, 4, 5]);
+ assert_eq!(vec.as_slice(), &[1, 2, 3, 4, 5]);
}
{
let mut vec = VectorOfi32::new();
vec.push(5);
vec.push(10);
- assert_eq!(vec.to_slice(), &[5, 10]);
+ assert_eq!(vec.as_slice(), &[5, 10]);
}
{
let vec = VectorOfPoint2d::from_iter(vec![Point2d::new(10., 20.), Point2d::new(60.5, 90.3), Point2d::new(-40.333, 89.)]);
- let slice = vec.to_slice();
+ let slice = vec.as_slice();
assert_eq!(20., slice[0].y);
assert_eq!(60.5, slice[1].x);
assert_eq!(Point2d::new(-40.333, 89.), slice[2]);

Rename Vec::as_slice to Vector::as_slice