Skip to content

Commit 2edb2f4

Browse files
author
Pascal Hertleif
authored
Fix typo in code example
Closes #47
1 parent c211fd2 commit 2edb2f4

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

_posts/2016-07-21-elegant-apis-in-rust.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,18 +459,19 @@ You can encode a state machine in the type system.
459459

460460
This works really well in Rust as your methods can move your data into a new type and you can no longer access the old state afterwards.
461461

462-
Here's an arbitrary example about mailing a package:
462+
Here's an arbitrary example about mailing a package
463+
(the type annotations are not necessary and are only added for clarity here):
463464

464465
```rust
465-
let p: OpenPackage = Package::new();
466-
let p: OpenPackage = package.insert([stuff, padding, padding]);
466+
let package: OpenPackage = Package::new();
467+
let package: OpenPackage = package.insert([stuff, padding, padding]);
467468

468-
let p: ClosedPackage = package.seal_up();
469+
let package: ClosedPackage = package.seal_up();
469470

470-
// let p: OpenPackage = package.insert([more_stuff]);
471+
// let package: OpenPackage = package.insert([more_stuff]);
471472
//~^ ERROR: No method named `insert` on `ClosedPackage`
472473

473-
let p: DeliveryTracking = package.send(address, postage);
474+
let package: DeliveryTracking = package.send(address, postage);
474475
```
475476

476477
A good real-life example was given by /u/ssokolow [in this thread on /r/rust](https://www.reddit.com/r/rust/comments/568yvh/typesafe_unions_in_c_and_rust/d8hcwfs):

0 commit comments

Comments
 (0)