Skip to content

Commit fb73b62

Browse files
authored
Followup to addition of apply
* inline code words easiest as backticks * prefer https to http * apply should not be "opinionated" about value vs reference, just transparently pass arguments through
1 parent 30d7cff commit fb73b62

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

std/typecons.d

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,28 +3441,29 @@ if (is (typeof(nullValue) == T))
34413441
assert(ntts.to!string() == "2.5");
34423442
}
34433443

3444+
// apply
34443445
/**
34453446
Unpacks the content of a $(D Nullable), performs an operation and packs it again. Does nothing if isNull.
34463447
3447-
When called on a $(D Nullable), $(D apply) will unpack the value contained in the $(D Nullable),
3448+
When called on a $(D Nullable), `apply` will unpack the value contained in the $(D Nullable),
34483449
pass it to the function you provide and wrap the result in another $(D Nullable) (if necessary).
3449-
If the Nullable is null, $(D apply) will return null itself.
3450+
If the Nullable is null, `apply` will return null itself.
34503451
34513452
Params:
3452-
t = a $(D Nullable)
3453+
t = a `Nullable`
34533454
fun = a function operating on the content of the nullable
34543455
34553456
Returns:
34563457
`fun(t.get).nullable` if `!t.isNull`, else `Nullable.init`.
34573458
34583459
See also:
3459-
$(HTTP en.wikipedia.org/wiki/Monad_(functional_programming)#The_Maybe_monad, The `Maybe` monad)
3460+
$(HTTPS en.wikipedia.org/wiki/Monad_(functional_programming)#The_Maybe_monad, The `Maybe` monad)
34603461
*/
34613462
template apply(alias fun)
34623463
{
34633464
import std.functional : unaryFun;
34643465

3465-
auto apply(T)(T t)
3466+
auto apply(T)(auto ref T t)
34663467
if (isInstanceOf!(Nullable, T) && is(typeof(unaryFun!fun(T.init.get))))
34673468
{
34683469
alias FunType = typeof(unaryFun!fun(T.init.get));

0 commit comments

Comments
 (0)