File: invariant.rs

package info (click to toggle)
rust-ghost 0.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: makefile: 2
file content (14 lines) | stat: -rw-r--r-- 315 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use ghost::phantom;

#[phantom]
struct InvariantPhantom<#[invariant] T>;

fn require_covariant<'a>(phantom: InvariantPhantom<&'static str>) -> InvariantPhantom<&'a str> {
    phantom
}

fn require_contravariant<'a>(phantom: InvariantPhantom<&'a str>) -> InvariantPhantom<&'static str> {
    phantom
}

fn main() {}