mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 15:27:32 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
33
mobile/ios/ThirdParty/Box/Box.swift
vendored
Normal file
33
mobile/ios/ThirdParty/Box/Box.swift
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2014 Rob Rix. All rights reserved.
|
||||
|
||||
/// Wraps a type `T` in a reference type.
|
||||
///
|
||||
/// Typically this is used to work around limitations of value types (for example, the lack of codegen for recursive value types and type-parameterized enums with >1 case). It is also useful for sharing a single (presumably large) value without copying it.
|
||||
public final class Box<T>: BoxType, CustomStringConvertible {
|
||||
/// Initializes a `Box` with the given value.
|
||||
public init(_ value: T) {
|
||||
self.value = value
|
||||
}
|
||||
|
||||
|
||||
/// Constructs a `Box` with the given `value`.
|
||||
public class func unit(_ value: T) -> Box<T> {
|
||||
return Box(value)
|
||||
}
|
||||
|
||||
|
||||
/// The (immutable) value wrapped by the receiver.
|
||||
public let value: T
|
||||
|
||||
/// Constructs a new Box by transforming `value` by `f`.
|
||||
public func map<U>(_ f: (T) -> U) -> Box<U> {
|
||||
return Box<U>(f(value))
|
||||
}
|
||||
|
||||
|
||||
// MARK: Printable
|
||||
|
||||
public var description: String {
|
||||
return String(describing: value)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue