浏览代码

rustfmt: format comments

This PR adds comment formatting configurations to the repository's `rustfmt.toml` file, and the associated changes from `cargo +nightly fmt --all`.

Comment width 80.
Joe C 2 年之前
父节点
当前提交
b282b0a2bd
共有 4 个文件被更改,包括 17 次插入12 次删除
  1. 8 7
      interface/src/instruction.rs
  2. 2 1
      interface/src/lib.rs
  3. 4 3
      interface/src/onchain.rs
  4. 3 1
      program/src/processor.rs

+ 8 - 7
interface/src/instruction.rs

@@ -26,8 +26,8 @@ pub enum TransferHookInstruction {
     ///   2. `[]` Destination account
     ///   3. `[]` Source account's owner/delegate
     ///   4. `[]` Validation account
-    ///   5..5+M `[]` `M` additional accounts, written in validation account data
-    ///
+    ///   5..5+M `[]` `M` additional accounts, written in validation account
+    ///     data
     Execute {
         /// Amount of tokens to transfer
         amount: u64,
@@ -41,15 +41,14 @@ pub enum TransferHookInstruction {
     ///   1. `[]` Mint
     ///   2. `[s]` Mint authority
     ///   3. `[]` System program
-    ///
     InitializeExtraAccountMetaList {
         /// List of `ExtraAccountMeta`s to write into the account
         extra_account_metas: Vec<ExtraAccountMeta>,
     },
 }
 /// TLV instruction type only used to define the discriminator. The actual data
-/// is entirely managed by `ExtraAccountMetaList`, and it is the only data contained
-/// by this type.
+/// is entirely managed by `ExtraAccountMetaList`, and it is the only data
+/// contained by this type.
 #[derive(SplDiscriminate)]
 #[discriminator_hash_input("spl-transfer-hook-interface:execute")]
 pub struct ExecuteInstruction;
@@ -61,7 +60,8 @@ pub struct ExecuteInstruction;
 pub struct InitializeExtraAccountMetaListInstruction;
 
 impl TransferHookInstruction {
-    /// Unpacks a byte buffer into a [TransferHookInstruction](enum.TransferHookInstruction.html).
+    /// Unpacks a byte buffer into a
+    /// [TransferHookInstruction](enum.TransferHookInstruction.html).
     pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
         if input.len() < ArrayDiscriminator::LENGTH {
             return Err(ProgramError::InvalidInstructionData);
@@ -87,7 +87,8 @@ impl TransferHookInstruction {
         })
     }
 
-    /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte buffer.
+    /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte
+    /// buffer.
     pub fn pack(&self) -> Vec<u8> {
         let mut buf = vec![];
         match self {

+ 2 - 1
interface/src/lib.rs

@@ -12,7 +12,8 @@ pub mod instruction;
 pub mod offchain;
 pub mod onchain;
 
-// Export current sdk types for downstream users building with a different sdk version
+// Export current sdk types for downstream users building with a different sdk
+// version
 pub use solana_program;
 use solana_program::pubkey::Pubkey;
 

+ 4 - 3
interface/src/onchain.rs

@@ -1,4 +1,5 @@
-//! On-chain program invoke helper to perform on-chain `execute` with correct accounts
+//! On-chain program invoke helper to perform on-chain `execute` with correct
+//! accounts
 
 use {
     crate::{error::TransferHookError, get_extra_account_metas_address, instruction},
@@ -53,8 +54,8 @@ pub fn invoke_execute<'a>(
     invoke(&cpi_instruction, &cpi_account_infos)
 }
 
-/// Helper to add accounts required for the transfer-hook program on-chain, looking
-/// through the additional account infos to add the proper accounts
+/// Helper to add accounts required for the transfer-hook program on-chain,
+/// looking through the additional account infos to add the proper accounts
 pub fn add_cpi_accounts_for_execute<'a>(
     cpi_instruction: &mut Instruction,
     cpi_account_infos: &mut Vec<AccountInfo<'a>>,

+ 3 - 1
program/src/processor.rs

@@ -73,7 +73,9 @@ pub fn process_execute(
     Ok(())
 }
 
-/// Processes a [InitializeExtraAccountMetaList](enum.TransferHookInstruction.html) instruction.
+/// Processes a
+/// [InitializeExtraAccountMetaList](enum.TransferHookInstruction.html)
+/// instruction.
 pub fn process_initialize_extra_account_meta_list(
     program_id: &Pubkey,
     accounts: &[AccountInfo],