Skip to content

Commit b95d03a

Browse files
Refactor OhShit enum by removing unused Int64 placeholders and simplifying return statements, add documentation
1 parent ddb36b5 commit b95d03a

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

Sources/ShitLib/ShitLib.swift

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,64 @@
11
//
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
44
//
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
69
//
710

11+
/// Enum with all the cases needed to wrap variables and magic numbers
812
public enum OhShit {
13+
/// `nil` value placeholder
914
public static let osNull: (any Sendable)? = nil
15+
/// Empty value placeholder
1016
public static let osEmpty = ""
1117

18+
/// `true` placeholder
1219
public static let osTrue = true
20+
/// `false` placeholder
1321
public static let osFalse = false
1422

23+
/// `-1` placeholder
1524
public static let osN1 = -1
25+
/// `0` placeholder
1626
public static let os0 = 0
27+
/// `1` placeholder
1728
public static let os1 = 1
1829

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
2333
public static func ohShit<T>(_ t: T?) -> T? {
24-
return t
34+
t
2535
}
2636

37+
/// Wraps an `Int` value.
38+
/// - Parameter i: The `Int` value you want to wrap
39+
/// - Returns: The same value passed as input
2740
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
3342
}
3443

44+
/// Wraps a `Character` value.
45+
/// - Parameter i: The `Character` value you want to wrap
46+
/// - Returns: The same value passed as input
3547
public static func ohShit(_ i: Character?) -> Character? {
36-
return i
48+
i
3749
}
3850

51+
/// Wraps a `Bool` value.
52+
/// - Parameter i: The `Bool` value you want to wrap
53+
/// - Returns: The same value passed as input
3954
public static func ohShit(_ i: Bool?) -> Bool? {
40-
return i
55+
i
4156
}
4257

58+
/// Wraps a `UInt8` value.
59+
/// - Parameter i: The `UInt8` value you want to wrap
60+
/// - Returns: The same value passed as input
4361
public static func ohShit(_ i: UInt8?) -> UInt8? {
44-
return i
62+
i
4563
}
4664
}

0 commit comments

Comments
 (0)