Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Bar {
- c: usize
- }
- impl Bar {
- fn add(&mut self) {
- self.c += 1;
- }
- }
- fn test(bar: Option<&mut Bar>) {
- for _ in 0..10 {
- if let Some(b) = bar {
- b.add();
- }
- }
- }
- fn main() {
- let mut bar = Bar{c: 0};
- test(Some(&mut bar));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement