e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
type Pair<A: Type, B: Type> {
|
|
left: A,
|
|
right: B,
|
|
}
|
|
|
|
type Box<T: Type> {
|
|
value: T,
|
|
fn rightOf<U: Type>(self: ref<Self>, pair: ref<Pair<T, U>>) -> U {
|
|
return pair.right
|
|
}
|
|
}
|
|
|
|
type PlainBox {
|
|
value: i32,
|
|
fn project<U: Type>(self: ref<Self>, pair: ref<Pair<Self, U>>) -> U {
|
|
return pair.right
|
|
}
|
|
}
|
|
|
|
interface Projector<T: Type> {
|
|
fn project<U: Type>(self: ref<T>, pair: ref<Pair<T, U>>) -> U
|
|
}
|
|
|
|
fn project<T: Projector<T>, U: Type>(value: ref<T>, pair: ref<Pair<T, U>>) -> U {
|
|
return T.project(value, pair)
|
|
}
|
|
|
|
pub fn main() -> Void {
|
|
let box: Box<i32> = Box { value: 1 }
|
|
let pair: Pair<i32, Bool> = Pair { left: 2, right: true }
|
|
let receiver: Bool = box.rightOf(&pair)
|
|
let namespaced: Bool = Box.rightOf(&box, &pair)
|
|
let plain: PlainBox = PlainBox { value: 3 }
|
|
let projectedPair: Pair<PlainBox, Bool> = Pair { left: PlainBox { value: 4 }, right: true }
|
|
let projected: Bool = project(&plain, &projectedPair)
|
|
expect (receiver && namespaced && projected)
|
|
}
|