July 19, 2023 [Issue 24049] New: std.conv.to: string to enum conversion is not documented | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24049 Issue ID: 24049 Summary: std.conv.to: string to enum conversion is not documented Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: snarwin+bugzilla@gmail.com std.conv.to supports conversion between enum types and string in both directions: --- import std.conv: to; enum Example { foo } unittest { assert(Example.foo.to!string == "foo"); assert("foo".to!Example == Example.foo); } --- However, only the enum-to-string conversion is mentioned in std.conv.to's documentation: > Stringize conversion from all types is supported. > [...] > * Enumerated types are converted to strings as their symbolic names. The conversion in the other direction, from string to enum type, is only mentioned in the documentation for std.conv.parse, where users of std.conv.to are likely to miss it. -- |
Copyright © 1999-2021 by the D Language Foundation