mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-01 15:18:39 +00:00
Contract variables can be declared in the `requires` clause and can be referenced both in `requires` and `ensures`, subject to usual borrow checking rules. This allows any setup common to both the `requires` and `ensures` clauses to only be done once.
16 lines
247 B
Rust
16 lines
247 B
Rust
//@ run-pass
|
|
//@ compile-flags: -Zcontract-checks=yes
|
|
#![feature(contracts_internals)]
|
|
|
|
fn outer() -> i32
|
|
contract_ensures { |ret| *ret > 0 }
|
|
{
|
|
let inner_closure = || -> i32 { 0 };
|
|
inner_closure();
|
|
10
|
|
}
|
|
|
|
fn main() {
|
|
outer();
|
|
}
|