Skip to content

Commit

Permalink
[stdlib] added ascii label to UInt8 UnicodeScalar constructor
Browse files Browse the repository at this point in the history
fixes rdar://problem/18509195

Swift SVN r25211
  • Loading branch information
mxswd committed Feb 12, 2015
1 parent 59bb06b commit 26ee4c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions stdlib/core/UnicodeScalar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ extension UnicodeScalar {
extension UInt8 {
/// Construct with value `v.value`.
///
/// Requires: `v.value` can be represented as UInt8.
public init(_ v : UnicodeScalar) {
_precondition(v.value <= UInt32(UInt8.max),
"Code point value does not fit into UInt8")
/// Requires: `v.value` can be represented as ASCII (0..<128).
public init(ascii v : UnicodeScalar) {
_precondition(v.value < 128,
"Code point value does not fit into ASCII")
self = UInt8(v.value)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/1_stdlib/PrimitiveDataTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var CharA: UnicodeScalar = "A" // 65 in decimal.

println(UInt8(CharA)) // CHECK: {{^65$}}
println(UInt8(ascii: CharA)) // CHECK: {{^65$}}
println(UInt32(CharA)) // CHECK: {{^65$}}
println(UInt64(CharA)) // CHECK: {{^65$}}

Expand Down

0 comments on commit 26ee4c3

Please sign in to comment.