Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ crate-type = ["cdylib", "rlib"]
anyhow = "1.0.75"
nom = "7.1.3"
pyo3 = "0.19.2"
serde = { version = "1.0.188", features = ["derive"] }
serde_yaml = "0.9.25"
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#![warn(clippy::redundant_closure_for_method_calls)]
#![warn(let_underscore_drop)]

mod list;
mod refs;

use pyo3::prelude::*;
Expand Down
22 changes: 22 additions & 0 deletions src/list/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mod removable;
mod unique;

/// Defines the shared interface between the unique list (which is effectively an insert-ordered
/// Set) and the unique list which supports removals.
pub trait List {
fn new() -> Self;
fn with_capacity(capacity: usize) -> Self;
fn len(&self) -> usize;
fn shrink_to_fit(&mut self);
fn append_if_new(&mut self, item: String);
fn merge(&mut self, other: Self);
fn merge_from(&mut self, other: &Self);
}

/// Returns the 0-indexed position of the item in the list, if it's found
fn item_pos(items: &[String], item: &String) -> Option<usize> {
items.iter().position(|v| v == item)
}

pub use removable::*;
pub use unique::*;
Loading