Skip to content

Commit 216189b

Browse files
committed
docs: add code doctest
1 parent 8e76373 commit 216189b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cast/src/lib.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ where
4444
/// Makes a read-only call to the specified address
4545
///
4646
/// ```no_run
47-
///
47+
///
4848
/// use cast::Cast;
4949
/// use ethers_core::types::Address;
5050
/// use ethers_providers::{Provider, Http};
@@ -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)