File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -197,4 +197,31 @@ extension FixedWidthInteger {
197
197
public init ? ( _ description: String ) {
198
198
self . init ( description, radix: 10 )
199
199
}
200
+
201
+ /// Creates a new integer value from the given Substring.
202
+ ///
203
+ /// Substring can be parsed at a high speed just by substituting strings.
204
+ ///
205
+ /// The Substring passed as `description` may begin with a plus or minus sign
206
+ /// character (`+` or `-`), followed by one or more numeric digits (`0-9`).
207
+ ///
208
+ /// let x = Int("123")
209
+ /// // x == 123
210
+ ///
211
+ /// If `description` is in an invalid format, or if the value it denotes in
212
+ /// base 10 is not representable, the result is `nil`. For example, the
213
+ /// following conversions result in `nil`:
214
+ ///
215
+ /// Int(" 100") // Includes whitespace
216
+ /// Int("21-50") // Invalid format
217
+ /// Int("ff6600") // Characters out of bounds
218
+ /// Int("10000000000000000000000000") // Out of range
219
+ ///
220
+ /// - Parameter description: The ASCII representation of a number.
221
+ @inlinable
222
+ @_semantics ( " optimize.sil.specialize.generic.partial.never " )
223
+ @inline ( __always)
224
+ public init ? ( _ description: Substring ) {
225
+ self . init ( String ( description) , radix: 10 )
226
+ }
200
227
}
You can’t perform that action at this time.
0 commit comments