-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from ThomasdenH/edition-and-docs
Update Cargo.toml and add `AsRef` and `AsMut`
- Loading branch information
Showing
6 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use core::error::Error; | ||
|
||
use iban::{BaseIban, Iban}; | ||
|
||
/// [`Iban`] implements [`AsRef`] to [`BaseIban`]. Test it here and see if it | ||
/// displays the same. | ||
#[test] | ||
fn test_as_ref() -> Result<(), Box<dyn Error>> { | ||
let iban: Iban = "KW81CBKU0000000000001234560101".parse()?; | ||
|
||
fn pretty_format(base_iban: impl AsRef<BaseIban>) -> String { | ||
let base_iban: &BaseIban = base_iban.as_ref(); | ||
base_iban.to_string() | ||
} | ||
|
||
let s = pretty_format(iban); | ||
assert_eq!(s.as_str(), "KW81 CBKU 0000 0000 0000 1234 5601 01"); | ||
assert_eq!(iban.to_string(), s); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters