forked from mirror/Riven
1
0
Fork 0

Update README.md doctest

users/mingwei/unknown-variant-messy
Mingwei Samuel 2021-09-09 14:54:02 -07:00
parent 74eb5fa045
commit f1a51693fa
2 changed files with 16 additions and 18 deletions

View File

@ -28,11 +28,10 @@ use riven::RiotApi;
use riven::consts::PlatformRoute; use riven::consts::PlatformRoute;
// Enter tokio async runtime. // Enter tokio async runtime.
let mut rt = tokio::runtime::Runtime::new().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async { rt.block_on(async {
// Create RiotApi instance from key string. // Create RiotApi instance from key string.
let api_key = "RGAPI-01234567-89ab-cdef-0123-456789abcdef"; let api_key = std::env!("RGAPI_KEY"); // "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
# /* (doc testing) */ let api_key = std::env!("RGAPI_KEY");
let riot_api = RiotApi::with_key(api_key); let riot_api = RiotApi::with_key(api_key);
// Get summoner data. // Get summoner data.
@ -52,7 +51,7 @@ rt.block_on(async {
// Print champioon masteries. // Print champioon masteries.
for (i, mastery) in masteries.iter().take(10).enumerate() { for (i, mastery) in masteries.iter().take(10).enumerate() {
println!("{: >2}) {: <9} {: >7} ({})", i + 1, println!("{: >2}) {: <9} {: >7} ({})", i + 1,
mastery.champion_id.to_string(), mastery.champion_id.name().unwrap_or("UNKNOWN"),
mastery.champion_points, mastery.champion_level); mastery.champion_points, mastery.champion_level);
} }
}); });
@ -60,14 +59,14 @@ rt.block_on(async {
Output: Output:
```text ```text
잘 못 Champion Masteries: 잘 못 Champion Masteries:
1) Riven 1219895 (7) 1) Riven 1236866 (7)
2) Fiora 229714 (5) 2) Fiora 230679 (5)
3) Katarina 175985 (5) 3) Katarina 175985 (5)
4) Lee Sin 150546 (7) 4) Lee Sin 156070 (7)
5) Jax 100509 (5) 5) Jax 102662 (5)
6) Gnar 76373 (6) 6) Gnar 76373 (6)
7) Kai'Sa 64271 (5) 7) Kai'Sa 64271 (5)
8) Caitlyn 46479 (5) 8) Caitlyn 46614 (5)
9) Irelia 46465 (5) 9) Irelia 46465 (5)
10) Vladimir 37176 (5) 10) Vladimir 37176 (5)
``` ```

View File

@ -38,11 +38,10 @@
//! use riven::consts::PlatformRoute; //! use riven::consts::PlatformRoute;
//! //!
//! // Enter tokio async runtime. //! // Enter tokio async runtime.
//! let mut rt = tokio::runtime::Runtime::new().unwrap(); //! let rt = tokio::runtime::Runtime::new().unwrap();
//! rt.block_on(async { //! rt.block_on(async {
//! // Create RiotApi instance from key string. //! // Create RiotApi instance from key string.
//! let api_key = "RGAPI-01234567-89ab-cdef-0123-456789abcdef"; //! let api_key = std::env!("RGAPI_KEY"); // "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
//! # /* (doc testing) */ let api_key = std::env!("RGAPI_KEY");
//! let riot_api = RiotApi::with_key(api_key); //! let riot_api = RiotApi::with_key(api_key);
//! //!
//! // Get summoner data. //! // Get summoner data.
@ -62,7 +61,7 @@
//! // Print champioon masteries. //! // Print champioon masteries.
//! for (i, mastery) in masteries.iter().take(10).enumerate() { //! for (i, mastery) in masteries.iter().take(10).enumerate() {
//! println!("{: >2}) {: <9} {: >7} ({})", i + 1, //! println!("{: >2}) {: <9} {: >7} ({})", i + 1,
//! mastery.champion_id.to_string(), //! mastery.champion_id.name().unwrap_or("UNKNOWN"),
//! mastery.champion_points, mastery.champion_level); //! mastery.champion_points, mastery.champion_level);
//! } //! }
//! }); //! });
@ -70,14 +69,14 @@
//! Output: //! Output:
//! ```text //! ```text
//! 잘 못 Champion Masteries: //! 잘 못 Champion Masteries:
//! 1) Riven 1219895 (7) //! 1) Riven 1236866 (7)
//! 2) Fiora 229714 (5) //! 2) Fiora 230679 (5)
//! 3) Katarina 175985 (5) //! 3) Katarina 175985 (5)
//! 4) Lee Sin 150546 (7) //! 4) Lee Sin 156070 (7)
//! 5) Jax 100509 (5) //! 5) Jax 102662 (5)
//! 6) Gnar 76373 (6) //! 6) Gnar 76373 (6)
//! 7) Kai'Sa 64271 (5) //! 7) Kai'Sa 64271 (5)
//! 8) Caitlyn 46479 (5) //! 8) Caitlyn 46614 (5)
//! 9) Irelia 46465 (5) //! 9) Irelia 46465 (5)
//! 10) Vladimir 37176 (5) //! 10) Vladimir 37176 (5)
//! ``` //! ```