Skip to content

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.

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.

}

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.

}

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