Skip to content

Commit

Permalink
Merge pull request #46 from kpp/patch-1
Browse files Browse the repository at this point in the history
Fix example in readme
  • Loading branch information
mxinden committed Jun 22, 2021
2 parents 658be9d + 3e54dd2 commit 95d5e64
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -36,14 +36,14 @@ then run `cargo build`.
```rust
extern crate multiaddr;

use multiaddr::{Multiaddr, ToMultiaddr};
use multiaddr::{Multiaddr, multiaddr};

let address = "/ip4/127.0.0.1/udp/1234".parse::<Multiaddr>().unwrap();
// or directly from a string
let other = "/ip4/127.0.0.1".to_multiaddr().unwrap();
let address = "/ip4/127.0.0.1/tcp/1234".parse::<Multiaddr>().unwrap();
// or with a macro
let other = multiaddr!(Ip4([127, 0, 0, 1]), Udp(10500u16), Quic);

assert_eq!(address.to_string(), "/ip4/127.0.0.1/udp/1234");
assert_eq!(other.to_string(), "/ip4/127.0.0.1");
assert_eq!(address.to_string(), "/ip4/127.0.0.1/tcp/1234");
assert_eq!(other.to_string(), "/ip4/127.0.0.1/udp/10500/quic");
```

## Maintainers
Expand Down

0 comments on commit 95d5e64

Please sign in to comment.