Motive behind !empty() with front() instead of Optional front()
Paul Backus
snarwin at gmail.com
Fri Mar 26 15:12:04 UTC 2021
On Friday, 26 March 2021 at 13:38:01 UTC, vitoroak wrote:
>
> I think one reason is that unlike Rust, D doesn't have a safe
> way to return Optional!(ref T) so we need front and empty so
> Ranges can return the items by reference.
I believe with DIP 1000 it should be possible to return something
like `Optional!(Ref!T)`, where `Ref!T` is a safe wrapper around a
`T*`.
Of course the ideal would be to make `ref` itself into a type
qualifier (`ref(T)`).
More information about the Digitalmars-d
mailing list