Coder Social home page Coder Social logo

Comments (8)

MingweiSamuel avatar MingweiSamuel commented on August 22, 2024

rust-lang/rust#95922

from hydroflow.

MingweiSamuel avatar MingweiSamuel commented on August 22, 2024
#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]

trait Gats {
    type Build<'a, 'b>: Fn() -> String;
    fn build<'a, 'b>(a: &'a str, b: &'b str) -> Self::Build<'a, 'b>;
}

type AlphaBuild<'a, 'b> = impl Fn() -> String;

struct Alpha;
impl Gats for Alpha {
    type Build<'a, 'b> = AlphaBuild<'a, 'b>;
    fn build<'a, 'b>(a: &'a str, b: &'b str) -> Self::Build<'a, 'b> {
        || format!("{}{}", a, b)
    }
}

Playground Link

from hydroflow.

MingweiSamuel avatar MingweiSamuel commented on August 22, 2024

doesn't quite reproduce

#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]

use std::fmt::Display;

trait GatsBase {
    type Build<'a, 'b>: Fn() -> String;
}
trait Gats: GatsBase {
    fn build<'a, 'b>(&'a self, b: &'b str) -> Self::Build<'a, 'b>;
}

type AlphaBuild<'a, 'b, T> = impl 'a + 'b + Fn() -> String;

struct Alpha<T: Display>(T);

impl<T: Display> GatsBase for Alpha<T> {
    type Build<'a, 'b> = AlphaBuild<'a, 'b, T>;
}
impl<T: Display> Gats for Alpha<T> {
    fn build<'a, 'b>(&'a self, b: &'b str) -> Self::Build<'a, 'b> {
        || format!("{}{}", self.0, b)
    }
}

from hydroflow.

aliemjay avatar aliemjay commented on August 22, 2024

I know nothing about hydroflow but noticed that adding move to the closure makes it pass.

Was it accpeted previously? That would be surprising!

from hydroflow.

MingweiSamuel avatar MingweiSamuel commented on August 22, 2024

updated playground

Thanks! Yeah, that does fix this example, so I guess this wasn't a reproduction of the issue we're having in hf itself. Still working on it.

more complicated playground also works

from hydroflow.

aliemjay avatar aliemjay commented on August 22, 2024

reproduced on playground

Fixed by adding where T: 'a to the GAT and to the type alias. playgound

from hydroflow.

MingweiSamuel avatar MingweiSamuel commented on August 22, 2024

Oh I didn't know the where Self: 'a clause let you bound other type parameters as 'a, I think that will work!

from hydroflow.

MingweiSamuel avatar MingweiSamuel commented on August 22, 2024

Although I guess writing where Self: 'a (instead of where T: 'a) also works? Since T is a parameter of Self, I guess.

from hydroflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.