Skip to content

Commit 1867057

Browse files
committed
fix failing doc tests
1 parent a6424c7 commit 1867057

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ anodized = "0.1.0"
2727

2828
Use the `#[contract]` attribute to define preconditions (`requires`), postconditions (`ensures`), and invariants (`maintains`). Each _condition_ is a standard Rust expression that evaluates to `bool`. In postconditions, the function's return value is available as `output`.
2929

30-
```rust
30+
```rust,ignore
3131
use anodized::contract;
3232
3333
#[contract(
@@ -51,7 +51,7 @@ fn main() {
5151

5252
In a **debug build** (`cargo run` or `cargo test`), your code is automatically instrumented to check the contracts. A contract violation will cause a panic with a descriptive error message:
5353

54-
```
54+
```ignore
5555
thread 'main' panicked at 'Precondition failed: divisor != 0', src/main.rs:17:5
5656
```
5757

@@ -89,7 +89,7 @@ A condition is a `bool`-valued Rust expression; as simple as that. This is a non
8989

9090
You can include any number of each flavor. Multiple conditions of the same flavor are combined with a logical **AND** (`&&`).
9191

92-
```rust
92+
```rust,ignore
9393
#[contract(
9494
// These two preconditions are equivalent to a single
9595
// precondition, `self.is_initialized && !self.is_locked`.
@@ -105,7 +105,7 @@ fn push(&mut self, value: T) { /* ... */ }
105105

106106
In **postconditions** (`ensures`), you can refer to the function's return value by the default name `output`.
107107

108-
```rust
108+
```rust,ignore
109109
#[contract(
110110
ensures: output > 0,
111111
)]
@@ -116,7 +116,7 @@ If the name `output` collides with an existing identifier, you can choose a diff
116116

117117
**1. Contract-Wide Binding**: Use the `binds` parameter to set a new name for the return value across all postconditions in the contract.
118118

119-
```rust
119+
```rust,ignore
120120
#[contract(
121121
binds: new_value,
122122
ensures: new_value > old_value,
@@ -126,7 +126,7 @@ fn increment(old_value: i32) -> i32 { /* ... */ }
126126

127127
**2. Closure Binding**: Write the postcondition as a closure. This has the highest precedence and affects only that single condition.
128128

129-
```rust
129+
```rust,ignore
130130
#[contract(
131131
// This postcondition uses the default binding `output`.
132132
ensures: output.is_valid(),
@@ -138,7 +138,7 @@ fn create_data() -> Data { /* ... */ }
138138

139139
**3. Binding Precedence**: The closure's binding takes precedence; same as in Rust. Plain postconditions still use the contract-wide binding.
140140

141-
```rust
141+
```rust,ignore
142142
// A function where 'output' is an argument name, requiring a different name.
143143
#[contract(
144144
// Set a contract-wide name for the return value: `result`.
@@ -155,7 +155,7 @@ fn calculate_even_result(output: i32) -> i32 { /* ... */ }
155155

156156
The `binds` parameter also lets you destructure return values, making complex postconditions easier to read and write. You can use any valid Rust pattern, including tuple patterns, struct patterns, or even more complex nested patterns.
157157

158-
```rust
158+
```rust,ignore
159159
use anodized::contract;
160160
161161
#[contract(

0 commit comments

Comments
 (0)