From 36402e5fa44178b45f6fd56e88533a2ff478b3b2 Mon Sep 17 00:00:00 2001 From: Jon C Date: Mon, 18 Nov 2024 22:58:51 +0100 Subject: [PATCH] Update doctests --- .../extension/interest_bearing_mint/mod.rs | 2 +- token/program-2022/src/extension/mod.rs | 6 ++--- token/program-2022/src/instruction.rs | 22 ++++++++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/token/program-2022/src/extension/interest_bearing_mint/mod.rs b/token/program-2022/src/extension/interest_bearing_mint/mod.rs index eca3916f0f0..bd2dc86c595 100644 --- a/token/program-2022/src/extension/interest_bearing_mint/mod.rs +++ b/token/program-2022/src/extension/interest_bearing_mint/mod.rs @@ -120,7 +120,7 @@ impl InterestBearingConfig { /// The new average rate is the time-weighted average of the current rate /// and average rate, solving for r such that: /// - /// ```no_run + /// ```text /// exp(r_1 * t_1) * exp(r_2 * t_2) = exp(r * (t_1 + t_2)) /// /// r_1 * t_1 + r_2 * t_2 = r * (t_1 + t_2) diff --git a/token/program-2022/src/extension/mod.rs b/token/program-2022/src/extension/mod.rs index 246d51813ae..76bdb092c8e 100644 --- a/token/program-2022/src/extension/mod.rs +++ b/token/program-2022/src/extension/mod.rs @@ -280,7 +280,7 @@ fn check_account_type(account_type: AccountType) -> Result<(), Pro /// Account with an extension, even if we add the account type. For example, /// let's say we have: /// -/// ```no_run +/// ```text /// Account: 165 bytes... + [2, 0, 3, 0, 100, ....] /// ^ ^ ^ ^ /// acct type extension length data... @@ -1367,8 +1367,8 @@ pub trait Extension { /// `size_of::() = 1`, `size_of::() = 2`, /// `size_of::() = 2`. /// -/// ```no_run -/// 355 - 165 - 1 - 2 - 2 = 185 +/// ``` +/// assert_eq!(355 - 165 - 1 - 2 - 2, 185); /// ``` #[cfg(test)] #[repr(C)] diff --git a/token/program-2022/src/instruction.rs b/token/program-2022/src/instruction.rs index 40a7d432845..1706271f5bb 100644 --- a/token/program-2022/src/instruction.rs +++ b/token/program-2022/src/instruction.rs @@ -1951,10 +1951,26 @@ pub fn decode_instruction_type>(input: &[u8]) -> Result { -/// let FirstData { ... } = decode_instruction_data(input)?; +/// let FirstData { a } = decode_instruction_data(&input).unwrap(); +/// assert_eq!(*a, 1); /// } /// } /// ```