use std::{ math::pi, iter::MapAdapter }
trait Area {
fn area(self): Float
}
type Shape {
Rect(width: Float, height: Float),
Circle(radius: Float),
}
impl Area for Shape {
fn area(self): Float {
match self {
Shape::Rect(width, height) { width * height }
Shape::Circle(radius) { pi * radius ^ 2. }
}
}
}
pub fn main() {
let shapes: List<Shape> = [
Shape::Rect(width: 4., height: 2.),
Shape::Circle(radius: 12.34),
]
println(
shapes
.iter()
.map(|s| s.area())
.collect<List<_>>()
.show()
)
}- Expressive type system
- Variant types and pattern matching
- Type class polymorphism with
traits - Errors are a part of a function type signature (using
std::result::Resultreturn type) - Automatic memory management
- Implicit last block line returns
| Feature | Milestone | Status |
|---|---|---|
| Lexing | 0.1.0 | ✅ |
| Parsing | 0.1.0 | ✅ |
| Semantic checking | 0.1.0 | ✅ |
| Type checking | 0.1.0 | ✅ |
| Code generation (JS target) | 0.1.0 | ✅ |
| Package support | 0.1.0 | ✅ |
| Useful standard library | 0.1.0 | 🚧 |
- ✅ Implemented
- 🚧 In progress
- ❌ TBD