Skip to content

Commit 6d90f0a

Browse files
committed
docs: add code doctest
1 parent 8e76373 commit 6d90f0a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cast/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,21 @@ where
286286
Ok(self.provider.get_gas_price().await?)
287287
}
288288

289+
/// ```no_run
290+
/// use cast::Cast;
291+
/// use ethers_providers::{Provider, Http};
292+
/// use ethers_core::types::Address;
293+
/// use std::{str::FromStr, convert::TryFrom};
294+
///
295+
/// # async fn foo() -> eyre::Result<()> {
296+
/// let provider = Provider::<Http>::try_from("http://localhost:8545")?;
297+
/// let cast = Cast::new(provider);
298+
/// let addr = Address::from_str("0x00000000219ab540356cbb839cbe05303d7705fa")?;
299+
/// let code = cast.code(addr, None).await?;
300+
/// println!("{}", code);
301+
/// # Ok(())
302+
/// # }
303+
/// ```
289304
pub async fn code<T: Into<NameOrAddress> + Send + Sync>(
290305
&self,
291306
who: T,

0 commit comments

Comments
 (0)