Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 36402e5

Browse files
committed
Update doctests
1 parent a851a31 commit 36402e5

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

token/program-2022/src/extension/interest_bearing_mint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl InterestBearingConfig {
120120
/// The new average rate is the time-weighted average of the current rate
121121
/// and average rate, solving for r such that:
122122
///
123-
/// ```no_run
123+
/// ```text
124124
/// exp(r_1 * t_1) * exp(r_2 * t_2) = exp(r * (t_1 + t_2))
125125
///
126126
/// r_1 * t_1 + r_2 * t_2 = r * (t_1 + t_2)

token/program-2022/src/extension/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn check_account_type<S: BaseState>(account_type: AccountType) -> Result<(), Pro
280280
/// Account with an extension, even if we add the account type. For example,
281281
/// let's say we have:
282282
///
283-
/// ```no_run
283+
/// ```text
284284
/// Account: 165 bytes... + [2, 0, 3, 0, 100, ....]
285285
/// ^ ^ ^ ^
286286
/// acct type extension length data...
@@ -1367,8 +1367,8 @@ pub trait Extension {
13671367
/// `size_of::<AccountType>() = 1`, `size_of::<ExtensionType>() = 2`,
13681368
/// `size_of::<Length>() = 2`.
13691369
///
1370-
/// ```no_run
1371-
/// 355 - 165 - 1 - 2 - 2 = 185
1370+
/// ```
1371+
/// assert_eq!(355 - 165 - 1 - 2 - 2, 185);
13721372
/// ```
13731373
#[cfg(test)]
13741374
#[repr(C)]

token/program-2022/src/instruction.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,10 +1951,26 @@ pub fn decode_instruction_type<T: TryFrom<u8>>(input: &[u8]) -> Result<T, Progra
19511951
/// instruction type as the first byte. This makes the code concise and safe
19521952
/// at the expense of clarity, allowing flows such as:
19531953
///
1954-
/// ```no_run
1955-
/// match decode_instruction_type(input)? {
1954+
/// ```
1955+
/// use spl_token_2022::instruction::{decode_instruction_data, decode_instruction_type};
1956+
/// use num_enum::TryFromPrimitive;
1957+
/// use bytemuck::{Pod, Zeroable};
1958+
///
1959+
/// #[repr(u8)]
1960+
/// #[derive(Clone, Copy, TryFromPrimitive)]
1961+
/// enum InstructionType {
1962+
/// First
1963+
/// }
1964+
/// #[derive(Pod, Zeroable, Copy, Clone)]
1965+
/// #[repr(transparent)]
1966+
/// struct FirstData {
1967+
/// a: u8,
1968+
/// }
1969+
/// let input = [0, 1];
1970+
/// match decode_instruction_type(&input).unwrap() {
19561971
/// InstructionType::First => {
1957-
/// let FirstData { ... } = decode_instruction_data(input)?;
1972+
/// let FirstData { a } = decode_instruction_data(&input).unwrap();
1973+
/// assert_eq!(*a, 1);
19581974
/// }
19591975
/// }
19601976
/// ```

0 commit comments

Comments
 (0)