Re: Returning range of inout objects from inout method

2020-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/25/20 4:07 PM, Steven Schveighoffer wrote: On 7/25/20 3:16 PM, FreeSlave wrote: On Saturday, 25 July 2020 at 14:19:15 UTC, Steven Schveighoffer wrote: The only way to do this without code duplication (but with generated code duplication) is to template the byAction function on the type o

Re: Returning range of inout objects from inout method

2020-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/25/20 3:16 PM, FreeSlave wrote: On Saturday, 25 July 2020 at 14:19:15 UTC, Steven Schveighoffer wrote: The only way to do this without code duplication (but with generated code duplication) is to template the byAction function on the type of `this`: auto byAction(this This)() { /* same

Re: Result and Option types

2020-07-25 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 25 July 2020 at 18:06:51 UTC, powerboat9 wrote: Does dlang have an analog to Result or Option types from rust? In addition to Nullable in the standard library, there are some packages on dub you might find useful: * optional: an option type that can also function as a range, for

Re: Returning range of inout objects from inout method

2020-07-25 Thread FreeSlave via Digitalmars-d-learn
On Saturday, 25 July 2020 at 14:19:15 UTC, Steven Schveighoffer wrote: The only way to do this without code duplication (but with generated code duplication) is to template the byAction function on the type of `this`: auto byAction(this This)() { /* same implementation */ } Note that this O

Re: Result and Option types

2020-07-25 Thread FreeSlave via Digitalmars-d-learn
On Saturday, 25 July 2020 at 18:06:51 UTC, powerboat9 wrote: Does dlang have an analog to Result or Option types from rust? Standard library has std.typecons.Nullable https://dlang.org/phobos/std_typecons.html#Nullable Note that objects are nullable by themselves as classes are reference ty

Result and Option types

2020-07-25 Thread powerboat9 via Digitalmars-d-learn
Does dlang have an analog to Result or Option types from rust?

Re: Returning range of inout objects from inout method

2020-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/25/20 8:26 AM, FreeSlave wrote: I want to be able to return a range of const objects from the const object and a range mutable objects from the mutable object. inout comes to mind, but not applicable in this case, because inout must be applied to the return type as whole, which does not m

Returning range of inout objects from inout method

2020-07-25 Thread FreeSlave via Digitalmars-d-learn
I want to be able to return a range of const objects from the const object and a range mutable objects from the mutable object. inout comes to mind, but not applicable in this case, because inout must be applied to the return type as whole, which does not make much sense for the range. Definin