aboutsummaryrefslogtreecommitdiff
path: root/primrose/src/library/eager_unique_vector.rs
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-10-06 11:12:09 +0100
committerAria <me@aria.rip>2023-10-06 11:12:09 +0100
commit776c2bae2b7b46e99fef82fe8ca45a27f541f133 (patch)
treed739721e0e172d3217020c82336fe351795698d5 /primrose/src/library/eager_unique_vector.rs
parent26126be56a2599eae76875fefbfe7db98e46213d (diff)
formatting fixes
Diffstat (limited to 'primrose/src/library/eager_unique_vector.rs')
-rw-r--r--primrose/src/library/eager_unique_vector.rs34
1 files changed, 16 insertions, 18 deletions
diff --git a/primrose/src/library/eager_unique_vector.rs b/primrose/src/library/eager_unique_vector.rs
index 0f4f389..ab7dddf 100644
--- a/primrose/src/library/eager_unique_vector.rs
+++ b/primrose/src/library/eager_unique_vector.rs
@@ -2,18 +2,18 @@
rust-eager-unique-vec-spec primrose::library::eager_unique_vector::EagerUniqueVec
*ENDLIBSPEC-NAME*/
-use std::vec::Vec;
-use std::slice::Iter;
-use std::ops::Deref;
-use crate::traits::{Container, Stack, Indexable};
+use crate::traits::{Container, Indexable, Stack};
use std::iter::FromIterator;
+use std::ops::Deref;
+use std::slice::Iter;
+use std::vec::Vec;
-use proptest::prelude::*;
-use crate::proptest::strategies::{eager_unique_vec};
+use crate::proptest::strategies::eager_unique_vec;
use crate::proptest::*;
+use proptest::prelude::*;
-use im::conslist::{ConsList};
use im::conslist;
+use im::conslist::ConsList;
use std::sync::Arc;
// A Unique Vector
@@ -30,7 +30,7 @@ impl<T: PartialEq> EagerUniqueVec<T> {
vec.push(i);
}
}
- EagerUniqueVec{ v: vec }
+ EagerUniqueVec { v: vec }
}
pub fn new() -> EagerUniqueVec<T> {
@@ -89,7 +89,6 @@ impl<T: PartialEq> EagerUniqueVec<T> {
Container
*ENDIMPL*/
impl<T: PartialEq> Container<T> for EagerUniqueVec<T> {
-
/*LIBSPEC*
/*OPNAME*
len op-len pre-len post-len
@@ -131,7 +130,7 @@ impl<T: PartialEq> Container<T> for EagerUniqueVec<T> {
/*LIBSPEC*
/*OPNAME*
- clear op-clear pre-clear post-clear
+ clear op-clear pre-clear post-clear
*ENDOPNAME*/
(define (op-clear xs) null)
(define (pre-clear xs) (equal? xs (remove-duplicates xs)))
@@ -166,10 +165,8 @@ impl<T: PartialEq> Container<T> for EagerUniqueVec<T> {
*ENDLIBSPEC*/
fn remove(&mut self, elt: T) -> Option<T> {
match self.iter().position(|x| *x == elt) {
- Some(index) => {
- Some(self.remove(index))
- },
- None => None
+ Some(index) => Some(self.remove(index)),
+ None => None,
}
}
}
@@ -222,11 +219,12 @@ impl<T: PartialEq> Indexable<T> for EagerUniqueVec<T> {
*ENDLIBSPEC*/
fn nth(&mut self, n: usize) -> Option<&T> {
EagerUniqueVec::iter(self).nth(n)
- }
+ }
}
fn abstraction<T>(v: EagerUniqueVec<T>) -> ConsList<T>
-where T: PartialEq
+where
+ T: PartialEq,
{
let list: ConsList<T> = ConsList::from(v.to_vec());
list
@@ -236,7 +234,7 @@ proptest! {
#![proptest_config(ProptestConfig {
cases: 100, .. ProptestConfig::default()
})]
-
+
#[test]
fn test_eager_unique_vec_len(ref mut v in eager_unique_vec(".*", 0..100)) {
let abs_list = abstraction(v.clone());
@@ -336,4 +334,4 @@ proptest! {
assert_eq!(elem, abs_nth);
assert_eq!(abstraction(v.clone()), abs_list);
}
-} \ No newline at end of file
+}