diff --git a/code/rust/src/stacks/stack.rs b/code/rust/src/stacks/stack.rs index a71a5a2..893f47e 100644 --- a/code/rust/src/stacks/stack.rs +++ b/code/rust/src/stacks/stack.rs @@ -18,7 +18,7 @@ pub struct Stack { } impl Stack -where T: Clone + ToString { +where T: Clone + ToString + Eq { /// Creates new typed instance of stack. pub fn new() -> Stack { return Stack { @@ -53,6 +53,11 @@ where T: Clone + ToString { return element; } + /// checks if element in stack: + pub fn contains(self: &Self, element: &T) -> bool { + return self.elements.contains(element); + } + /// convert entries to strings #[allow(dead_code)] fn repr(self: &Self) -> Vec {