Y combinator: Difference between revisions

Content deleted Content added
m →‎{{header|Rust}}: Fix deprecated trait object (needs explicit dyn)
m →‎{{header|Rust}}: Fixed some more deprecated trait objects
Line 4,324: Line 4,324:
fn apply(
fn apply(
&self,
&self,
f: &Apply<T, R>,
f: &dyn Apply<T, R>,
t: T
t: T
) -> R;
) -> R;
Line 4,341: Line 4,341:
// And it is a little bit more efficient for Fn closures as it do not clone itself.
// And it is a little bit more efficient for Fn closures as it do not clone itself.
impl<T, R, F> Apply<T, R> for F where F:
impl<T, R, F> Apply<T, R> for F where F:
Fn(&Apply<T, R>, T) -> R
Fn(&dyn Apply<T, R>, T) -> R
{
{
fn apply(
fn apply(
&self,
&self,
f: &Apply<T, R>,
f: &dyn Apply<T, R>,
t: T
t: T
) -> R {
) -> R {
Line 4,375: Line 4,375:
fn y<T,R>(f:impl Fn(&dyn Fn(T) -> R, T) -> R) -> impl Fn(T) -> R {
fn y<T,R>(f:impl Fn(&dyn Fn(T) -> R, T) -> R) -> impl Fn(T) -> R {
move |t| (
move |t| (
|x: &Apply<T,R>, y| x.apply(x, y)
|x: &dyn Apply<T,R>, y| x.apply(x, y)
) (
) (
&|x: &Apply<T,R>, y| f(
&|x: &dyn Apply<T,R>, y| f(
&|z| x.apply(x,z),
&|z| x.apply(x,z),
y
y