Skip to content

Commit

Permalink
fix scope warnings, fix #196
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Jul 5, 2023
1 parent c25a0eb commit 7037833
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/containers/hashmap.d
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
/**
* Returns: a range of the keys in this map.
*/
auto byKey(this This)() inout @trusted
auto byKey(this This)() inout @safe return scope
{
return MapRange!(This, IterType.key)(cast(Unqual!(This)*) &this);
return MapRange!(This, IterType.key)((() @trusted => cast(Unqual!(This)*) &this)());
}

/**
Expand All @@ -271,9 +271,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
/**
* Returns: a range of the values in this map.
*/
auto byValue(this This)() inout @trusted
auto byValue(this This)() inout @safe return scope
{
return MapRange!(This, IterType.value)(cast(Unqual!(This)*) &this);
return MapRange!(This, IterType.value)((() @trusted => cast(Unqual!(This)*) &this)());
}

/// ditto
Expand Down Expand Up @@ -303,9 +303,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
* Returns: a range of the kev/value pairs in this map. The element type of
* this range is a struct with `key` and `value` fields.
*/
auto byKeyValue(this This)() inout @trusted
auto byKeyValue(this This)() inout @safe return scope
{
return MapRange!(This, IterType.both)(cast(Unqual!(This)*) &this);
return MapRange!(This, IterType.both)((() @trusted => cast(Unqual!(This)*) &this)());
}

/**
Expand Down Expand Up @@ -431,7 +431,7 @@ private:

private:

this(Unqual!(MapType)* hm)
this(Unqual!(MapType)* hm) @safe
{
this.hm = hm;
this.bucketIndex = 0;
Expand Down
14 changes: 8 additions & 6 deletions src/containers/ttree.d
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ private:
return r;
}

void rotateLeft(ref Node* root, AllocatorType allocator) @safe
void rotateLeft(ref Node* root, AllocatorType allocator) @trusted
{
Node* newRoot;
if (right.left !is null && right.right is null)
Expand Down Expand Up @@ -927,7 +927,7 @@ private:
cleanup(newRoot, root, allocator);
}

void rotateRight(ref Node* root, AllocatorType allocator) @safe
void rotateRight(ref Node* root, AllocatorType allocator) @trusted
{
Node* newRoot;
if (left.right !is null && left.left is null)
Expand Down Expand Up @@ -959,10 +959,12 @@ private:
{
if (newRoot.parent !is null)
{
if (newRoot.parent.right is &this)
newRoot.parent.right = newRoot;
else
newRoot.parent.left = newRoot;
(() @trusted {
if (newRoot.parent.right is &this)
newRoot.parent.right = newRoot;
else
newRoot.parent.left = newRoot;
})();
}
else
root = newRoot;
Expand Down

0 comments on commit 7037833

Please sign in to comment.