fix: expose if necessary

This commit is contained in:
Miwa / Ensan
2025-06-15 19:38:46 +09:00
parent 14be26541d
commit c2c7cbf031
2 changed files with 20 additions and 20 deletions

View File

@@ -18,7 +18,7 @@ package extension Sequence {
} }
} }
package extension Collection { public extension Collection {
/// Returns a `Set` containing the elements of this sequence with transformed values. /// Returns a `Set` containing the elements of this sequence with transformed values.
/// - Parameters: /// - Parameters:
/// - transform: A closure that transforms each element of this sequence into a value that can be hashed. /// - transform: A closure that transforms each element of this sequence into a value that can be hashed.
@@ -60,7 +60,7 @@ package extension Collection {
} }
} }
package extension MutableCollection { public extension MutableCollection {
/// Calls the given closure with a pointer to the array's mutable contiguous storage. /// Calls the given closure with a pointer to the array's mutable contiguous storage.
/// - Parameter /// - Parameter
/// - transform: A closure that takes a pointer to the array's mutable contiguous storage. /// - transform: A closure that takes a pointer to the array's mutable contiguous storage.
@@ -71,7 +71,7 @@ package extension MutableCollection {
} }
} }
package extension Collection { public extension Collection {
/// Returns a SubSequence containing the elements of this sequence up to the first element that does not satisfy the given predicate. /// Returns a SubSequence containing the elements of this sequence up to the first element that does not satisfy the given predicate.
/// - Parameters: /// - Parameters:
/// - condition: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included. /// - condition: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included.
@@ -85,7 +85,7 @@ package extension Collection {
} }
} }
package extension Collection where Self.Element: Equatable { public extension Collection where Self.Element: Equatable {
/// Returns a Bool value indicating whether the collection has the given prefix. /// Returns a Bool value indicating whether the collection has the given prefix.
/// - Parameters: /// - Parameters:
/// - prefix: A collection to search for at the start of this collection. /// - prefix: A collection to search for at the start of this collection.

View File

@@ -6,26 +6,26 @@
// Copyright © 2020 ensan. All rights reserved. // Copyright © 2020 ensan. All rights reserved.
// //
import Foundation public import Foundation
package extension StringProtocol { extension StringProtocol {
/// ///
/// - note: `false` /// - note: `false`
@usableFromInline @inlinable
var onlyRomanAlphabetOrNumber: Bool { package var onlyRomanAlphabetOrNumber: Bool {
!isEmpty && range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil !isEmpty && range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
} }
/// ///
/// - note: `false` /// - note: `false`
@usableFromInline @inlinable
var onlyRomanAlphabet: Bool { package var onlyRomanAlphabet: Bool {
!isEmpty && range(of: "[^a-zA-Z]", options: .regularExpression) == nil !isEmpty && range(of: "[^a-zA-Z]", options: .regularExpression) == nil
} }
/// ///
/// - note: `false` /// - note: `false`
/// 40 /// 40
@inlinable @inlinable
var containsRomanAlphabet: Bool { package var containsRomanAlphabet: Bool {
for value in self.utf8 { for value in self.utf8 {
if (UInt8(ascii: "a") <= value && value <= UInt8(ascii: "z")) || (UInt8(ascii: "A") <= value && value <= UInt8(ascii: "Z")) { if (UInt8(ascii: "a") <= value && value <= UInt8(ascii: "z")) || (UInt8(ascii: "A") <= value && value <= UInt8(ascii: "Z")) {
return true return true
@@ -35,21 +35,21 @@ package extension StringProtocol {
} }
/// ///
/// - note: `false` /// - note: `false`
@usableFromInline @inlinable
var isEnglishSentence: Bool { public var isEnglishSentence: Bool {
!isEmpty && range(of: "[^0-9a-zA-Z\n !'_<>\\[\\]{}*@`\\^|~=\"#$%&\\+\\(\\),\\-\\./:;?\\\\]", options: .regularExpression) == nil !isEmpty && range(of: "[^0-9a-zA-Z\n !'_<>\\[\\]{}*@`\\^|~=\"#$%&\\+\\(\\),\\-\\./:;?\\\\]", options: .regularExpression) == nil
} }
/// ///
@usableFromInline @usableFromInline
var isKana: Bool { package var isKana: Bool {
!isEmpty && range(of: "[^ぁ-ゖァ-ヶ]", options: .regularExpression) == nil !isEmpty && range(of: "[^ぁ-ゖァ-ヶ]", options: .regularExpression) == nil
} }
/// Returns a String value in which Hiraganas are all converted to Katakana. /// Returns a String value in which Hiraganas are all converted to Katakana.
/// - Returns: A String value in which Hiraganas are all converted to Katakana. /// - Returns: A String value in which Hiraganas are all converted to Katakana.
@usableFromInline @inlinable
func toKatakana() -> String { public func toKatakana() -> String {
// utf162utf16 // utf162utf16
let result = self.utf16.map { scalar -> UInt16 in let result = self.utf16.map { scalar -> UInt16 in
if 0x3041 <= scalar && scalar <= 0x3096 { if 0x3041 <= scalar && scalar <= 0x3096 {
@@ -63,8 +63,8 @@ package extension StringProtocol {
/// Returns a String value in which Katakana are all converted to Hiragana. /// Returns a String value in which Katakana are all converted to Hiragana.
/// - Returns: A String value in which Katakana are all converted to Hiragana. /// - Returns: A String value in which Katakana are all converted to Hiragana.
@usableFromInline @inlinable
func toHiragana() -> String { public func toHiragana() -> String {
// utf162utf16 // utf162utf16
let result = self.utf16.map { scalar -> UInt16 in let result = self.utf16.map { scalar -> UInt16 in
if 0x30A1 <= scalar && scalar <= 0x30F6 { if 0x30A1 <= scalar && scalar <= 0x30F6 {
@@ -87,7 +87,7 @@ package extension StringProtocol {
" -> \d " -> \d
*/ */
// please use these letters in order to avoid user-inputting text crash // please use these letters in order to avoid user-inputting text crash
func templateDataSpecificEscaped() -> String { package func templateDataSpecificEscaped() -> String {
var result = self.replacingOccurrences(of: "\\", with: "\\b") var result = self.replacingOccurrences(of: "\\", with: "\\b")
result = result.replacingOccurrences(of: "\0", with: "\\0") result = result.replacingOccurrences(of: "\0", with: "\\0")
result = result.replacingOccurrences(of: "\n", with: "\\n") result = result.replacingOccurrences(of: "\n", with: "\\n")
@@ -98,7 +98,7 @@ package extension StringProtocol {
return result return result
} }
func templateDataSpecificUnescaped() -> String { package func templateDataSpecificUnescaped() -> String {
var result = self.replacingOccurrences(of: "\\d", with: "\"") var result = self.replacingOccurrences(of: "\\d", with: "\"")
result = result.replacingOccurrences(of: "\\s", with: " ") result = result.replacingOccurrences(of: "\\s", with: " ")
result = result.replacingOccurrences(of: "\\c", with: ",") result = result.replacingOccurrences(of: "\\c", with: ",")