feat: Begin using Tagged types
All checks were successful
CI / Linux Tests (push) Successful in 5m23s
All checks were successful
CI / Linux Tests (push) Successful in 5m23s
This commit is contained in:
@@ -1,4 +1,17 @@
|
||||
import Foundation
|
||||
import Tagged
|
||||
|
||||
extension Tagged where RawValue == Double {
|
||||
public func string(digits: Int = 2) -> String {
|
||||
rawValue.string(digits: digits)
|
||||
}
|
||||
}
|
||||
|
||||
extension Tagged where RawValue == Int {
|
||||
public func string() -> String {
|
||||
rawValue.string()
|
||||
}
|
||||
}
|
||||
|
||||
extension Double {
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ public struct FrictionRate: Codable, Equatable, Sendable {
|
||||
/// minus the ``ComponentPressureLoss``es for the project.
|
||||
public let availableStaticPressure: Double
|
||||
/// The calculated design friction rate value.
|
||||
public let value: Double
|
||||
public let value: DesignFrictionRate
|
||||
/// Whether the design friction rate is within a valid range.
|
||||
public var hasErrors: Bool { error != nil }
|
||||
|
||||
public init(
|
||||
availableStaticPressure: Double,
|
||||
value: Double
|
||||
value: DesignFrictionRate
|
||||
) {
|
||||
self.availableStaticPressure = availableStaticPressure
|
||||
self.value = value
|
||||
|
||||
7
Sources/ManualDCore/TaggedTypes.swift
Normal file
7
Sources/ManualDCore/TaggedTypes.swift
Normal file
@@ -0,0 +1,7 @@
|
||||
import Tagged
|
||||
|
||||
public enum CFMTag {}
|
||||
public typealias CFM = Tagged<CFMTag, Int>
|
||||
|
||||
public enum DesignFrictionRateTag {}
|
||||
public typealias DesignFrictionRate = Tagged<DesignFrictionRateTag, Double>
|
||||
Reference in New Issue
Block a user