From 5ce805c5432f5ff28d443c08c5df95c155904545 Mon Sep 17 00:00:00 2001 From: raj_mathe Date: Thu, 14 Apr 2022 11:55:31 +0200 Subject: [PATCH] =?UTF-8?q?master=20>=20master:=20code-rust=20-=20`.contai?= =?UTF-8?q?ns`=20methode=20f=C3=BCr=20stacks=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/rust/src/stacks/stack.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 {