Browse Source

rustfmt: format imports

This PR adds import formatting configurations to the repository's `rustfmt.toml` file, and the associated changes from `cargo +nightly fmt --all`.
Joe C 1 year ago
parent
commit
c3f12a1f62

+ 6 - 4
program/src/entrypoint.rs

@@ -1,9 +1,11 @@
 //! Program entrypoint
 //! Program entrypoint
 
 
-use crate::{error::TokenError, processor::Processor};
-use solana_program::{
-    account_info::AccountInfo, entrypoint::ProgramResult, program_error::PrintProgramError,
-    pubkey::Pubkey,
+use {
+    crate::{error::TokenError, processor::Processor},
+    solana_program::{
+        account_info::AccountInfo, entrypoint::ProgramResult, program_error::PrintProgramError,
+        pubkey::Pubkey,
+    },
 };
 };
 
 
 solana_program::entrypoint!(process_instruction);
 solana_program::entrypoint!(process_instruction);

+ 8 - 6
program/src/error.rs

@@ -1,12 +1,14 @@
 //! Error types
 //! Error types
 
 
-use num_derive::FromPrimitive;
-use solana_program::{
-    decode_error::DecodeError,
-    msg,
-    program_error::{PrintProgramError, ProgramError},
+use {
+    num_derive::FromPrimitive,
+    solana_program::{
+        decode_error::DecodeError,
+        msg,
+        program_error::{PrintProgramError, ProgramError},
+    },
+    thiserror::Error,
 };
 };
-use thiserror::Error;
 
 
 /// Errors that may be returned by the Token program.
 /// Errors that may be returned by the Token program.
 #[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
 #[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]

+ 10 - 9
program/src/instruction.rs

@@ -1,15 +1,16 @@
 //! Instruction types
 //! Instruction types
 
 
-use crate::{check_program_account, error::TokenError};
-use solana_program::{
-    instruction::{AccountMeta, Instruction},
-    program_error::ProgramError,
-    program_option::COption,
-    pubkey::Pubkey,
-    sysvar,
+use {
+    crate::{check_program_account, error::TokenError},
+    solana_program::{
+        instruction::{AccountMeta, Instruction},
+        program_error::ProgramError,
+        program_option::COption,
+        pubkey::Pubkey,
+        sysvar,
+    },
+    std::{convert::TryInto, mem::size_of},
 };
 };
-use std::convert::TryInto;
-use std::mem::size_of;
 
 
 /// Minimum number of multisignature signers (min N)
 /// Minimum number of multisignature signers (min N)
 pub const MIN_SIGNERS: usize = 1;
 pub const MIN_SIGNERS: usize = 1;

+ 1 - 2
program/src/native_mint.rs

@@ -8,8 +8,7 @@ solana_program::declare_id!("So11111111111111111111111111111111111111112");
 
 
 #[cfg(test)]
 #[cfg(test)]
 mod tests {
 mod tests {
-    use super::*;
-    use solana_program::native_token::*;
+    use {super::*, solana_program::native_token::*};
 
 
     #[test]
     #[test]
     fn test_decimals() {
     fn test_decimals() {

+ 36 - 32
program/src/processor.rs

@@ -1,24 +1,26 @@
 //! Program state processor
 //! Program state processor
 
 
-use crate::{
-    amount_to_ui_amount_string_trimmed,
-    error::TokenError,
-    instruction::{is_valid_signer_index, AuthorityType, TokenInstruction, MAX_SIGNERS},
-    state::{Account, AccountState, Mint, Multisig},
-    try_ui_amount_into_amount,
-};
-use solana_program::{
-    account_info::{next_account_info, AccountInfo},
-    entrypoint::ProgramResult,
-    msg,
-    program::set_return_data,
-    program_error::ProgramError,
-    program_memory::sol_memcmp,
-    program_option::COption,
-    program_pack::{IsInitialized, Pack},
-    pubkey::{Pubkey, PUBKEY_BYTES},
-    system_program,
-    sysvar::{rent::Rent, Sysvar},
+use {
+    crate::{
+        amount_to_ui_amount_string_trimmed,
+        error::TokenError,
+        instruction::{is_valid_signer_index, AuthorityType, TokenInstruction, MAX_SIGNERS},
+        state::{Account, AccountState, Mint, Multisig},
+        try_ui_amount_into_amount,
+    },
+    solana_program::{
+        account_info::{next_account_info, AccountInfo},
+        entrypoint::ProgramResult,
+        msg,
+        program::set_return_data,
+        program_error::ProgramError,
+        program_memory::sol_memcmp,
+        program_option::COption,
+        program_pack::{IsInitialized, Pack},
+        pubkey::{Pubkey, PUBKEY_BYTES},
+        system_program,
+        sysvar::{rent::Rent, Sysvar},
+    },
 };
 };
 
 
 /// Program state handler.
 /// Program state handler.
@@ -1028,20 +1030,22 @@ fn delete_account(account_info: &AccountInfo) -> Result<(), ProgramError> {
 
 
 #[cfg(test)]
 #[cfg(test)]
 mod tests {
 mod tests {
-    use super::*;
-    use crate::instruction::*;
-    use serial_test::serial;
-    use solana_program::{
-        account_info::IntoAccountInfo,
-        clock::Epoch,
-        instruction::Instruction,
-        program_error::{self, PrintProgramError},
-        sysvar::rent,
-    };
-    use solana_sdk::account::{
-        create_account_for_test, create_is_signer_account_infos, Account as SolanaAccount,
+    use {
+        super::*,
+        crate::instruction::*,
+        serial_test::serial,
+        solana_program::{
+            account_info::IntoAccountInfo,
+            clock::Epoch,
+            instruction::Instruction,
+            program_error::{self, PrintProgramError},
+            sysvar::rent,
+        },
+        solana_sdk::account::{
+            create_account_for_test, create_is_signer_account_infos, Account as SolanaAccount,
+        },
+        std::sync::{Arc, RwLock},
     };
     };
-    use std::sync::{Arc, RwLock};
 
 
     lazy_static::lazy_static! {
     lazy_static::lazy_static! {
         static ref EXPECTED_DATA: Arc<RwLock<Vec<u8>>> = Arc::new(RwLock::new(Vec::new()));
         static ref EXPECTED_DATA: Arc<RwLock<Vec<u8>>> = Arc::new(RwLock::new(Vec::new()));

+ 10 - 8
program/src/state.rs

@@ -1,13 +1,15 @@
 //! State transition types
 //! State transition types
 
 
-use crate::instruction::MAX_SIGNERS;
-use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
-use num_enum::TryFromPrimitive;
-use solana_program::{
-    program_error::ProgramError,
-    program_option::COption,
-    program_pack::{IsInitialized, Pack, Sealed},
-    pubkey::{Pubkey, PUBKEY_BYTES},
+use {
+    crate::instruction::MAX_SIGNERS,
+    arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs},
+    num_enum::TryFromPrimitive,
+    solana_program::{
+        program_error::ProgramError,
+        program_option::COption,
+        program_pack::{IsInitialized, Pack, Sealed},
+        pubkey::{Pubkey, PUBKEY_BYTES},
+    },
 };
 };
 
 
 /// Mint data.
 /// Mint data.