mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 16:58:38 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
27
mobile/ios/ThirdParty/Box/MutableBox.swift
vendored
Normal file
27
mobile/ios/ThirdParty/Box/MutableBox.swift
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) 2014 Rob Rix. All rights reserved.
|
||||
|
||||
/// Wraps a type `T` in a mutable reference type.
|
||||
///
|
||||
/// While this, like `Box<T>` could be used to work around limitations of value types, it is much more useful for sharing a single mutable value such that mutations are shared.
|
||||
///
|
||||
/// As with all mutable state, this should be used carefully, for example as an optimization, rather than a default design choice. Most of the time, `Box<T>` will suffice where any `BoxType` is needed.
|
||||
public final class MutableBox<T>: MutableBoxType, CustomStringConvertible {
|
||||
/// Initializes a `MutableBox` with the given value.
|
||||
public init(_ value: T) {
|
||||
self.value = value
|
||||
}
|
||||
|
||||
/// The (mutable) value wrapped by the receiver.
|
||||
public var value: T
|
||||
|
||||
/// Constructs a new MutableBox by transforming `value` by `f`.
|
||||
public func map<U>(_ f: (T) -> U) -> MutableBox<U> {
|
||||
return MutableBox<U>(f(value))
|
||||
}
|
||||
|
||||
// MARK: Printable
|
||||
|
||||
public var description: String {
|
||||
return String(describing: value)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue