Skip to content

v0.4.0

Compare
Choose a tag to compare
@niuez niuez released this 28 Aug 11:50
· 213 commits to master since this release
  • Features
    • Add<Arg>のような、Generics付きTraitを実装しました #23
    • これに伴い、二項演算がそれぞれTraitに対応し、C++側ではdecltypeによるSFINAEが行われるようになりました #24
  • Bug Fix
    • SFINAEの変換が壊れていた部分を修正
    • Selfの変換が壊れていたのを修正
trait Add<Arg> {
  type Output;
  fn add(a: Self, b: Arg) -> Self#Add<Arg>::Output;
}

impl Add<u64> for u64 {
  type Output = u64;
  fn add(a: Self, b: u64) -> u64 $${a + b}$$
}

struct Hoge<S> {
  s: S,
} {}

impl<S> Add<Hoge<S>> for Hoge<S> where S: Add<S> {
  type Output = S#Add<S>::Output;
  fn add(self: Self, right: Self) -> S#Add<S>::Output {
    self.s + right.s
  }
}

fn try_add<S, T>(s: S, t: T) -> S#Add<T>::Output where S: Add<T> {
  let ans = s + t;
  ans
}

fn main() -> void {
  let a = Hoge { s: 9u64 };
  let b = Hoge { s: 1u64 };
  let c = a + b;
}