|
@@ -572,19 +572,13 @@ impl Data {
|
|
matches!(self, Self::Map(_))
|
|
matches!(self, Self::Map(_))
|
|
}
|
|
}
|
|
pub fn push(&mut self, v: Data) {
|
|
pub fn push(&mut self, v: Data) {
|
|
- match self {
|
|
|
|
- Self::Vec(vec) => {
|
|
|
|
- vec.push(v);
|
|
|
|
- }
|
|
|
|
- _ => (),
|
|
|
|
|
|
+ if let Self::Vec(vec) = self {
|
|
|
|
+ vec.push(v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pub fn insert(&mut self, k: String, v: Data) {
|
|
pub fn insert(&mut self, k: String, v: Data) {
|
|
- match self {
|
|
|
|
- Self::Map(hm) => {
|
|
|
|
- hm.insert(k, v);
|
|
|
|
- }
|
|
|
|
- _ => (),
|
|
|
|
|
|
+ if let Self::Map(hm) = self {
|
|
|
|
+ hm.insert(k, v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pub fn len(&self) -> usize {
|
|
pub fn len(&self) -> usize {
|
|
@@ -623,10 +617,7 @@ impl Data {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pub fn truncate(&mut self, len: usize) {
|
|
pub fn truncate(&mut self, len: usize) {
|
|
- match self {
|
|
|
|
- Self::Vec(v) => v.truncate(len),
|
|
|
|
- _ => (),
|
|
|
|
- }
|
|
|
|
|
|
+ if let Self::Vec(v) = self { v.truncate(len) }
|
|
}
|
|
}
|
|
pub fn remove(&mut self, index: usize) -> Data {
|
|
pub fn remove(&mut self, index: usize) -> Data {
|
|
match self {
|
|
match self {
|
|
@@ -656,10 +647,7 @@ impl Data {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pub fn resize(&mut self, len: usize, value: Data) {
|
|
pub fn resize(&mut self, len: usize, value: Data) {
|
|
- match self {
|
|
|
|
- Self::Vec(v) => v.resize(len, value),
|
|
|
|
- _ => (),
|
|
|
|
- }
|
|
|
|
|
|
+ if let Self::Vec(v) = self { v.resize(len, value) }
|
|
}
|
|
}
|
|
pub fn first(&self) -> Option<&Data> {
|
|
pub fn first(&self) -> Option<&Data> {
|
|
match self {
|
|
match self {
|
|
@@ -690,7 +678,7 @@ impl Data {
|
|
I: SliceIndex<[Data]>,
|
|
I: SliceIndex<[Data]>,
|
|
{
|
|
{
|
|
match self {
|
|
match self {
|
|
- Self::Vec(v) => v.get::<I>(index.into()),
|
|
|
|
|
|
+ Self::Vec(v) => v.get::<I>(index),
|
|
_ => None,
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -704,16 +692,10 @@ impl Data {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pub fn swap(&mut self, a: usize, b: usize) {
|
|
pub fn swap(&mut self, a: usize, b: usize) {
|
|
- match self {
|
|
|
|
- Self::Vec(v) => v.swap(a, b),
|
|
|
|
- _ => (),
|
|
|
|
- }
|
|
|
|
|
|
+ if let Self::Vec(v) = self { v.swap(a, b) }
|
|
}
|
|
}
|
|
pub fn reverse(&mut self) {
|
|
pub fn reverse(&mut self) {
|
|
- match self {
|
|
|
|
- Self::Vec(v) => v.reverse(),
|
|
|
|
- _ => (),
|
|
|
|
- }
|
|
|
|
|
|
+ if let Self::Vec(v) = self { v.reverse() }
|
|
}
|
|
}
|
|
pub fn vec_iter(&self) -> Option<Iter<'_, Data>> {
|
|
pub fn vec_iter(&self) -> Option<Iter<'_, Data>> {
|
|
match self {
|
|
match self {
|