Re: std.conv:to that does not throw?

2025-01-30 Thread Lance Bachmeier via Digitalmars-d-learn
On Thursday, 30 January 2025 at 01:38:07 UTC, Kyle Ingraham wrote: Does D have a 'try' `std.conv:to` that does not throw if it fails? Have you looked at [mir.conv](http://mir-core.libmir.org/mir_conv.html) and [mir.parse](http://mir-algorithm.libmir.org/mir_parse.html)?

Re: std.conv:to that does not throw?

2025-01-30 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 30 January 2025 at 01:38:07 UTC, Kyle Ingraham wrote: Does D have a 'try' `std.conv:to` that does not throw if it fails? Something like: ```D string input = "9"; int output; auto parsed = input.tryTo!int(output); ``` You could try something like this: ```d import std.typecons: Nu