1use std::ops::{Deref, DerefMut};
4
5#[derive(Debug, Clone, PartialEq)]
7pub struct Vector<T>(pub Vec<T>);
8
9impl<T> Vector<T> {
10 pub fn new(data: Vec<T>) -> Self {
12 Vector(data)
13 }
14
15 pub fn into_vec(self) -> Vec<T> {
17 self.0
18 }
19}
20
21impl<T> From<Vec<T>> for Vector<T> {
22 fn from(vec: Vec<T>) -> Self {
23 Vector(vec)
24 }
25}
26
27impl<T> Into<Vec<T>> for Vector<T> {
28 fn into(self) -> Vec<T> {
29 self.0
30 }
31}
32
33impl<T> Deref for Vector<T> {
34 type Target = Vec<T>;
35
36 fn deref(&self) -> &Self::Target {
37 &self.0
38 }
39}
40
41impl<T> DerefMut for Vector<T> {
42 fn deref_mut(&mut self) -> &mut Self::Target {
43 &mut self.0
44 }
45}
46
47pub trait IntoVector<T> {
49 fn into_vector(self) -> Vector<T>;
50}
51
52impl<T> IntoVector<T> for Vec<T> {
53 fn into_vector(self) -> Vector<T> {
54 Vector::new(self)
55 }
56}
57