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

Conform CircularBuffer to ExpressibleByArrayLiteral #1102

Merged
merged 1 commit into from Aug 12, 2019

Conversation

@adtrevor
Copy link
Contributor

commented Aug 11, 2019

Motivation

Making CircularBuffer conform to ExpressibleByArrayLiteral enables directly initializing it from an array literal, which can sometimes make its use simpler and more natural, for instance:

foo.circularBuffer = [1,2,3] // vs = CircularBuffer([1,2,3])
Foo(circularBuffer: [a, b, c]) // vs : CircularBuffer([a, b, c])

This is consistent with other standard Swift collections, such as
Set, as well as existing NIO types (eg: WebSocketMaskingKey).

Modifications

Extend CircularBuffer to conform to ExpressibleByArrayLiteral

Result

CircularBuffer can now be initialized from array literals

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

8 similar comments
@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@swift-nio-bot

This comment has been minimized.

Copy link

commented Aug 11, 2019

Can one of the admins verify this patch?

@adtrevor adtrevor force-pushed the adtrevor:arrayliteralcb branch 2 times, most recently from b0810df to 5b3b20a Aug 11, 2019

@Lukasa Lukasa requested a review from weissi Aug 12, 2019

@Lukasa Lukasa added this to the 2.7.0 milestone Aug 12, 2019

@Lukasa
Copy link
Contributor

left a comment

A couple small notes in the test, otherwise this look just fine.

Tests/NIOTests/CircularBufferTests.swift Outdated Show resolved Hide resolved
Tests/NIOTests/CircularBufferTests.swift Outdated Show resolved Hide resolved

@adtrevor adtrevor force-pushed the adtrevor:arrayliteralcb branch from 5b3b20a to ffc2552 Aug 12, 2019

@adtrevor

This comment has been minimized.

Copy link
Contributor Author

commented Aug 12, 2019

@Lukasa Tests are fixed now! 🙂

Conform CircularBuffer to ExpressibleByArrayLiteral
Motivation:
Making CircularBuffer conform to ExpressibleByArrayLiteral enables
directly initializing it from an array literal, which can sometimes
make its use simpler and more natural, for instance:
foo.circularBuffer = [1,2,3] // vs `= CircularBuffer([1,2,3])`
Foo(circularBuffer: [a, b, c]) // vs `: CircularBuffer([a, b, c])`
This is consistent with other standard Swift collections, such as
Set, as well as existing NIO types (eg: WebSocketMaskingKey).

Modifications:
Extend CircularBuffer to conform to ExpressibleByArrayLiteral

Result:
CircularBuffer can now be initialized from array literals

@adtrevor adtrevor force-pushed the adtrevor:arrayliteralcb branch from ffc2552 to 33e8887 Aug 12, 2019

@Lukasa

Lukasa approved these changes Aug 12, 2019

Copy link
Contributor

left a comment

Seems good.

@Lukasa

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2019

@swift-nio-bot test this please

@weissi

weissi approved these changes Aug 12, 2019

Copy link
Member

left a comment

nice! thank you

@Lukasa Lukasa merged commit a28a866 into apple:master Aug 12, 2019

4 checks passed

pull request validation (5.0) Build finished.
Details
pull request validation (5.1) Build finished.
Details
pull request validation (api breakage) Build finished.
Details
pull request validation (sanity) Build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.