make Queue fully @safe to use

This commit is contained in:
Cameron Ross 2018-04-22 18:35:07 -03:00
parent e269cba70c
commit 44c5d9d085
No known key found for this signature in database
GPG key ID: 777897D98DC91C54

View file

@ -99,7 +99,7 @@ struct Queue(T)
} }
/// Push new item to the queue. /// Push new item to the queue.
void push(T item) @trusted nothrow void push(T item) @safe nothrow
{ {
Node* newLast = newNode(item, null); Node* newLast = newNode(item, null);
if(last_ !is null) { last_.next_ = newLast; } if(last_ !is null) { last_.next_ = newLast; }
@ -109,7 +109,7 @@ struct Queue(T)
} }
/// Insert a new item putting it to specified index in the linked list. /// Insert a new item putting it to specified index in the linked list.
void insert(T item, const size_t idx) @trusted nothrow void insert(T item, const size_t idx) @safe nothrow
in in
{ {
assert(idx <= length_); assert(idx <= length_);
@ -136,7 +136,7 @@ struct Queue(T)
} }
/// Return the next element in the queue and remove it. /// Return the next element in the queue and remove it.
T pop() @trusted nothrow T pop() @safe nothrow
in in
{ {
assert(!empty, "Trying to pop an element from an empty queue"); assert(!empty, "Trying to pop an element from an empty queue");