Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@msakai
Created September 30, 2021 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msakai/a7fa962c64cfa6166a845cfa62631e01 to your computer and use it in GitHub Desktop.
Save msakai/a7fa962c64cfa6166a845cfa62631e01 to your computer and use it in GitHub Desktop.
{-# LANGUAGE FlexibleContexts, GADTs, TypeFamilies #-}
class T a where
type Config a
getConfig :: a -> Config a
data D where
T :: T a => a -> D
trait T {
type Config;
fn getConfig(&self) -> Self::Config;
}
enum D {
T(Box<dyn T>)
}
/*
error[E0191]: the value of the associated type `Config` (from trait `T`) must be specified
--> test_associated_types.rs:7:15
|
2 | type Config;
| ------------ `Config` defined here
...
7 | T(Box<dyn T>)
| ^ help: specify the associated type: `T<Config = Type>`
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment