Skip to content

Commit

Permalink
Merge pull request #1208 from botahamec/function-use-declaration-example
Browse files Browse the repository at this point in the history
Moved the option variant imports
  • Loading branch information
ehuss authored May 9, 2022
2 parents fd564da + 868850d commit b8ac38e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/items/use-declarations.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ Use declarations support a number of convenient shortcuts:
An example of `use` declarations:

```rust
use std::option::Option::{Some, None};
use std::collections::hash_map::{self, HashMap};

fn foo<T>(_: T){}
fn bar(map1: HashMap<String, usize>, map2: hash_map::HashMap<String, usize>){}

fn main() {
// use declarations can also exist inside of functions
use std::option::Option::{Some, None};

// Equivalent to 'foo(vec![std::option::Option::Some(1.0f64),
// std::option::Option::None]);'
foo(vec![Some(1.0f64), None]);
Expand Down

0 comments on commit b8ac38e

Please sign in to comment.