Files
bitchat/localPackages/BitFoundation/Sources/BitFoundation/String+Ext.swift
T
IslamandGitHub 4cfcefcda6 BitFoundation module to centralize shared components (#1089)
* Run local packages’ tests as well on CI

* BitFoundation module to centralize shared components
2026-04-14 14:10:03 -05:00

23 lines
491 B
Swift

//
// String+Ext.swift
// BitFoundation
//
// This is free and unencumbered software released into the public domain.
// For more information, see <https://unlicense.org>
//
public extension StringProtocol {
var trimmed: String {
trimmingCharacters(in: .whitespacesAndNewlines)
}
var trimmedOrNilIfEmpty: String? {
let trimmed = self.trimmed
return trimmed.isEmpty ? nil : trimmed
}
var nilIfEmpty: Self? {
isEmpty ? nil : self
}
}