Skip to content

Commit a670e09

Browse files
Alpha.1 - fix some deps and small fix
1 parent 7c7a96e commit a670e09

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

rust/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "platform-data"
3-
version = "0.1.0-aplha.0"
3+
version = "0.1.0-aplha.1"
44
edition = "2018"
55
authors = ["uselesssgoddess", "Linksplatform Team <linksplatformtechnologies@gmail.com>"]
66
license = "LGPL-3.0"
@@ -16,5 +16,3 @@ tempfile = "3.2.0"
1616
num-traits = "0.2.14"
1717

1818
platform-num = { version = "0.1.0-aplha.0" }
19-
platform-mem = { version = "0.1.0-aplha.4" }
20-
platform-treesmethods = { version = "0.1.0-aplha.0" }

rust/src/query.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,78 @@
11
use platform_num::LinkType;
2-
use std::borrow::Cow;
2+
use std::borrow::{Borrow, Cow};
33
use std::ops::Index;
44
use std::slice::SliceIndex;
55

66
#[derive(Clone, Debug, PartialEq, Eq)]
7-
pub struct Query<'a, T: LinkType> {
8-
cow: Cow<'a, [T]>,
9-
}
7+
pub struct Query<'a, T: Clone>(Cow<'a, [T]>);
108

11-
impl<'a, T: LinkType> Query<'a, T> {
9+
impl<'a, T: Clone> Query<'a, T> {
1210
pub fn new<C>(beef: C) -> Self
1311
where
1412
C: Into<Cow<'a, [T]>>,
1513
{
16-
Query { cow: beef.into() }
14+
Query(beef.into())
1715
}
1816

1917
pub fn len(&self) -> usize {
20-
match self.cow {
21-
Cow::Borrowed(ref beef) => beef.len(),
18+
match self.0 {
19+
Cow::Borrowed(beef) => beef.len(),
2220
Cow::Owned(ref beef) => beef.len(),
2321
}
2422
}
2523

2624
pub fn into_inner(self) -> Cow<'a, [T]> {
27-
self.cow
25+
self.0
2826
}
2927

3028
pub fn into_owned(self) -> Vec<T> {
31-
match self.cow {
32-
Cow::Borrowed(beef) => beef.to_vec(),
29+
match self.0 {
30+
Cow::Borrowed(beef) => beef.to_owned(),
3331
Cow::Owned(beef) => beef,
3432
}
3533
}
3634
}
3735

38-
impl<'a, I: SliceIndex<[T]>, T: LinkType> Index<I> for Query<'a, T> {
36+
impl<'a, I: SliceIndex<[T]>, T: Clone> Index<I> for Query<'a, T> {
3937
type Output = I::Output;
4038

4139
fn index(&self, index: I) -> &Self::Output {
42-
match self.cow {
40+
match self.0 {
4341
Cow::Borrowed(ref s) => &s[index],
4442
Cow::Owned(ref s) => &s[index],
4543
}
4644
}
4745
}
4846

49-
pub trait ToQuery<T: LinkType> {
47+
pub trait ToQuery<T: Clone> {
5048
fn to_query(&self) -> Query<'_, T>;
5149
}
5250

53-
impl<T: LinkType> ToQuery<T> for Query<'_, T> {
51+
impl<T: Clone> ToQuery<T> for Query<'_, T> {
5452
fn to_query(&self) -> Query<'_, T> {
5553
Query::new(&self[..])
5654
}
5755
}
5856

59-
impl<T: LinkType> ToQuery<T> for [T] {
57+
impl<T: Clone> ToQuery<T> for [T] {
6058
fn to_query(&self) -> Query<'_, T> {
6159
Query::new(self)
6260
}
6361
}
6462

65-
impl<'a, T: LinkType> ToQuery<T> for &'a [T] {
63+
impl<'a, T: Clone> ToQuery<T> for &'a [T] {
6664
fn to_query(&self) -> Query<'a, T> {
6765
Query::new(*self)
6866
}
6967
}
7068

71-
impl<T: LinkType> ToQuery<T> for Vec<T> {
69+
impl<T: Clone> ToQuery<T> for Vec<T> {
7270
fn to_query(&self) -> Query<'_, T> {
7371
Query::new(&self[..])
7472
}
7573
}
7674

77-
impl<T: LinkType, const L: usize> ToQuery<T> for [T; L] {
75+
impl<T: Clone, const L: usize> ToQuery<T> for [T; L] {
7876
fn to_query(&self) -> Query<'_, T> {
7977
Query::new(&self[..])
8078
}

rust/tests/query.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use platform_data::{query, Query, ToQuery};
2+
3+
#[test]
4+
fn by_ref() {
5+
let query = query![1, 2, 3];
6+
let ref_query = &query;
7+
let query = ref_query.to_query();
8+
}

0 commit comments

Comments
 (0)