///|
#warnings("-deprecated")
test "parse_int" {
inspect(@strconv.parse_int("42"), content="42")
inspect(@strconv.parse_int("101", base=2), content="5")
inspect(@strconv.parse_int("ff", base=16), content="255")
}///|
#warnings("-deprecated")
test "parse_int64_uint" {
inspect(
@strconv.parse_int64("9223372036854775807"),
content="9223372036854775807",
)
inspect(@strconv.parse_uint("42"), content="42")
inspect(
@strconv.parse_uint64("18446744073709551615"),
content="18446744073709551615",
)
}///|
#warnings("-deprecated")
test "parse_other" {
inspect(@strconv.parse_bool("true"), content="true")
inspect(@strconv.parse_double("3.14"), content="3.14")
}///|
#warnings("-deprecated")
test "from_str" {
let i : Int = @strconv.from_str("123")
inspect(i, content="123")
let b : Bool = @strconv.from_str("false")
inspect(b, content="false")
let d : Double = @strconv.from_str("2.718")
inspect(d, content="2.718")
}///|
#warnings("-deprecated")
test "error_handling" {
let result : Result[Int, _] = try! @strconv.parse_int("abc")
inspect(result is Err(_), content="true")
}#deprecated("use `@string.FromStr` instead")
pub(open) trait FromStr {
#deprecated("use `@string.from_str` instead")
#as_free_fn
fn from_str(StringView) -> Self raise StrConvError = _
#deprecated("use `@string.from_str` instead")
fn from_string(String) -> Self raise StrConvError = _
}#deprecated("use `@string` parsing APIs instead")
pub(all) suberror StrConvError {
StrConvError(String)
} derive(Debug)impl Show for StrConvError#deprecated("use `@string.parse_double` instead")
fn Decimal::parse_decimal(str : StringView) -> Decimal raise StrConvError#deprecated("use `@string.parse_double` instead")
fn Decimal::to_double(self : Decimal) -> Double raise StrConvError#deprecated("use `@string.from_str` instead")
fn[A : FromStr] parse(str : StringView) -> A raise StrConvError#deprecated("use `@string.parse_bool` instead")
fn parse_bool(str : StringView) -> Bool raise StrConvError#deprecated("use `@string.parse_double` instead")
fn parse_decimal(str : StringView) -> Decimal raise StrConvError#deprecated("use `@string.parse_double` instead")
fn parse_double(str : StringView) -> Double raise StrConvError#warnings("-deprecated")
test {
inspect(@strconv.parse_double("123"), content="123")
inspect(@strconv.parse_double("12.34"), content="12.34")
inspect(@strconv.parse_double(".123"), content="0.123")
inspect(@strconv.parse_double("1e5"), content="100000")
inspect(@strconv.parse_double("1.2e-3"), content="0.0012")
inspect(@strconv.parse_double("1_234.5"), content="1234.5")
}#deprecated("use `@string.parse_int` instead")
fn parse_int(str : StringView, base? : Int) -> Int raise StrConvError#deprecated("use `@string.parse_int64` instead")
fn parse_int64(str : StringView, base? : Int) -> Int64 raise StrConvError#warnings("-deprecated")
test {
inspect(@strconv.parse_int64("123"), content="123")
inspect(@strconv.parse_int64("0xff", base=0), content="255")
inspect(@strconv.parse_int64("0o10"), content="8")
inspect(@strconv.parse_int64("0b1010"), content="10")
inspect(@strconv.parse_int64("1_234"), content="1234")
inspect(@strconv.parse_int64("-123"), content="-123")
inspect(@strconv.parse_int64("ff", base=16), content="255")
inspect(@strconv.parse_int64("zz", base=36), content="1295")
}#deprecated("use `@string.parse_uint` instead")
fn parse_uint(str : StringView, base? : Int) -> UInt raise StrConvError#deprecated("use `@string.parse_uint64` instead")
fn parse_uint64(str : StringView, base? : Int) -> UInt64 raise StrConvError#warnings("-deprecated")
test {
inspect(@strconv.parse_uint64("123"), content="123")
inspect(@strconv.parse_uint64("0xff", base=0), content="255")
inspect(@strconv.parse_uint64("0o10"), content="8")
inspect(@strconv.parse_uint64("0b1010"), content="10")
inspect(@strconv.parse_uint64("1_234"), content="1234")
inspect(@strconv.parse_uint64("ff", base=16), content="255")
inspect(@strconv.parse_uint64("zz", base=36), content="1295")
}Install
Installed by default