- Notifications
You must be signed in to change notification settings - Fork 228
Open
Labels
meta-classesrequestRequests to resolve a particular developer problemRequests to resolve a particular developer problem
Description
Hi, trying to produce some generic code, I discovered that interfaces can't have non-implemented static methods.
But it would be a nice feature to allow this.
I can illustrate it by this piece of Rust code:
struct A { damn: i32 } trait Serializable { fn from_integer(nb: i32) -> Self; } impl Serializable for A { fn from_integer(nb: i32) -> Self { A { damn: nb } } } fn bar<T: Serializable>(nb: i32) -> T { T::from_integer(nb) } pub fn main() { let wow = bar::<A>(10); println!("{}", wow.damn); }I tried to produce a non-working equivalent in Dart:
abstract class Serializable { static fromInteger(int); } class A implements Serializable { int foo; A(this.foo); A fromInteger(int nb) { return A(nb); } } T bar<T extends Serializable>(int nb) { return T.fromInteger(nb); } main() { var wow = bar<A>(42); print(wow.foo); } LifeIsStrange, nicolidin, Rodsevich, michaelspiss, carmas123 and 293 moreamsakanna, tbm98, popiosifcristian, masreplay, rasitayaz and 14 moreamsakanna, AlexBacich, wallforfry, nicolidin, mateusfccp and 39 moreamsakanna, wallforfry, nicolidin, Manuelbaun, mateusfccp and 38 moreViShadowFiend, JakubBatel, SunlightBro, masreplay, rasitayaz and 11 more
Metadata
Metadata
Assignees
Labels
meta-classesrequestRequests to resolve a particular developer problemRequests to resolve a particular developer problem