master > master: code-rust - .contains
methode für stacks hinzugefügt
This commit is contained in:
parent
07b214bc24
commit
5ce805c543
@ -18,7 +18,7 @@ pub struct Stack<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Stack<T>
|
impl<T> Stack<T>
|
||||||
where T: Clone + ToString {
|
where T: Clone + ToString + Eq {
|
||||||
/// Creates new typed instance of stack.
|
/// Creates new typed instance of stack.
|
||||||
pub fn new() -> Stack<T> {
|
pub fn new() -> Stack<T> {
|
||||||
return Stack {
|
return Stack {
|
||||||
@ -53,6 +53,11 @@ where T: Clone + ToString {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// checks if element in stack:
|
||||||
|
pub fn contains(self: &Self, element: &T) -> bool {
|
||||||
|
return self.elements.contains(element);
|
||||||
|
}
|
||||||
|
|
||||||
/// convert entries to strings
|
/// convert entries to strings
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn repr(self: &Self) -> Vec<String> {
|
fn repr(self: &Self) -> Vec<String> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user