Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scope warnings, fix #196 #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix scope warnings, fix #196 #197

wants to merge 1 commit into from

Conversation

WebFreak001
Copy link
Member

No description provided.

Comment on lines +245 to +247
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)());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're returning &this, not this, so the correct lifetime annotation here is return ref (i.e., return, since the ref on this is implicit), not return scope.

Comment on lines +274 to +276
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)());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment on lines +306 to +308
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)());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@@ -431,7 +431,7 @@ private:

private:

this(Unqual!(MapType)* hm)
this(Unqual!(MapType)* hm) @safe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler should be able to infer this.

@@ -899,7 +899,7 @@ private:
return r;
}

void rotateLeft(ref Node* root, AllocatorType allocator) @safe
void rotateLeft(ref Node* root, AllocatorType allocator) @trusted
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be @trusted? How do we know that what it's doing is memory safe? Please add a comment for future maintainers.

@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

newRoot.parent.right = newRoot;
else
newRoot.parent.left = newRoot;
(() @trusted {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants