|
1 | 1 | // |
2 | | -// ShitLib.h |
3 | | -// ShitLib |
| 2 | +// OhShit.swift - Enum with all the cases needed to wrap variables and magic numbers |
| 3 | +// This source file is part of the ShitLib open source project |
4 | 4 | // |
5 | | -// Created by Cristina De Rito on 25/02/2018. |
| 5 | +// Copyright (c) 2018 - 2025 ShitLib |
| 6 | +// Licensed under MIT |
| 7 | +// |
| 8 | +// See https://github.com/ShitLib/shitlib-swift/blob/main/LICENSE for license information |
6 | 9 | // |
7 | 10 |
|
| 11 | +/// Enum with all the cases needed to wrap variables and magic numbers |
8 | 12 | public enum OhShit { |
| 13 | + /// `nil` value placeholder |
9 | 14 | public static let osNull: (any Sendable)? = nil |
| 15 | + /// Empty value placeholder |
10 | 16 | public static let osEmpty = "" |
11 | 17 |
|
| 18 | + /// `true` placeholder |
12 | 19 | public static let osTrue = true |
| 20 | + /// `false` placeholder |
13 | 21 | public static let osFalse = false |
14 | 22 |
|
| 23 | + /// `-1` placeholder |
15 | 24 | public static let osN1 = -1 |
| 25 | + /// `0` placeholder |
16 | 26 | public static let os0 = 0 |
| 27 | + /// `1` placeholder |
17 | 28 | public static let os1 = 1 |
18 | 29 |
|
19 | | - public static let osN1I64: Int64 = -1 |
20 | | - public static let os0I64: Int64 = 0 |
21 | | - public static let os1I64: Int64 = 1 |
22 | | - |
| 30 | + /// Wraps a value of any type which conforms to `Sendable`. |
| 31 | + /// - Parameter t: The value you want to wrap |
| 32 | + /// - Returns: The same value passed as input |
23 | 33 | public static func ohShit<T>(_ t: T?) -> T? { |
24 | | - return t |
| 34 | + t |
25 | 35 | } |
26 | 36 |
|
| 37 | + /// Wraps an `Int` value. |
| 38 | + /// - Parameter i: The `Int` value you want to wrap |
| 39 | + /// - Returns: The same value passed as input |
27 | 40 | public static func ohShit(_ i: Int?) -> Int? { |
28 | | - return i |
29 | | - } |
30 | | - |
31 | | - public static func ohShit(_ i: Int64?) -> Int64? { |
32 | | - return i |
| 41 | + i |
33 | 42 | } |
34 | 43 |
|
| 44 | + /// Wraps a `Character` value. |
| 45 | + /// - Parameter i: The `Character` value you want to wrap |
| 46 | + /// - Returns: The same value passed as input |
35 | 47 | public static func ohShit(_ i: Character?) -> Character? { |
36 | | - return i |
| 48 | + i |
37 | 49 | } |
38 | 50 |
|
| 51 | + /// Wraps a `Bool` value. |
| 52 | + /// - Parameter i: The `Bool` value you want to wrap |
| 53 | + /// - Returns: The same value passed as input |
39 | 54 | public static func ohShit(_ i: Bool?) -> Bool? { |
40 | | - return i |
| 55 | + i |
41 | 56 | } |
42 | 57 |
|
| 58 | + /// Wraps a `UInt8` value. |
| 59 | + /// - Parameter i: The `UInt8` value you want to wrap |
| 60 | + /// - Returns: The same value passed as input |
43 | 61 | public static func ohShit(_ i: UInt8?) -> UInt8? { |
44 | | - return i |
| 62 | + i |
45 | 63 | } |
46 | 64 | } |
0 commit comments