Closed oluseyi closed 7 years ago
The final interface doesn't require the user ever cast to NSUInteger
—that is entirely hidden as an implementation detail:
let windowStyleMask = NSTitledWindowMask|
NSClosableWindowMask|
NSMiniaturizableWindowMask|
NSResizableWindowMask|
NSUnifiedTitleAndToolbarWindowMask|
NSFullSizeContentViewWindowMask;
let window = NSWindow::alloc(nil)
.initWithContentRect_styleMask_backing_defer_(windowFrame,
windowStyleMask,
NSBackingStoreBuffered,
NO)
.autorelease();
Getting started with
cocoa-rs
as an experienced Objective-C Cocoa developer, I tried to modify the example at https://github.com/servo/cocoa-rs/blob/master/examples/hello_world.rs with multiple window style masks, converting the combined value toNSUInteger
:Of course, this didn't work. I feel that
cocoa-rs
should strive to offer idiomatic interfaces wherever possible, so I looked into the implementation and feel that an elegant approach that preserves strong type information is possible.