You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: utils.rs
    path of file: ./repos/foundry/crates/wallets/src
    
    the code of the file until where you have to start completion: use crate::{error::PrivateKeyError, PendingSigner, WalletSigner};
use ethers_signers::{HDPath as LedgerHDPath, LocalWallet, TrezorHDPath, WalletError};
use eyre::{Context, Result};
use foundry_conf
    
pub fn create_private_key_signer(private_key: &str) -> Result<WalletSigner> {
    let privk = private_key.trim().strip_prefix("0x").unwrap_or(private_key);
    match LocalWallet::from_str(privk) {
        Ok(pk) => Ok(WalletSigner::Local(pk)),
        Err(err) => {
            // helper closure to check if pk was meant to be an env var, this usually happens if
            // `$` is missing
            let ensure_not_env = |pk: &str| {
                // check if pk was meant to be an env var
                if !pk.starts_with("0x") && std::env::var(pk).is_ok() {
                    // SAFETY: at this point we know the user actually wanted to use an env var
                    // and most likely forgot the `$` anchor, so the
                    // `private_key` here is an unresolved env var
                    return Err(PrivateKeyError::ExistsAsEnvVar(pk.to_string()))
                }
                Ok(())
            };
            match err {
                WalletError::HexError(err) => {
                    ensure_not_env(private_key)?;
                    return Err(PrivateKeyError::InvalidHex(err).into());
                }
                WalletError::EcdsaError(_) => ensure_not_env(private_key)?,
                _ => {}
            };
            eyre::bail!("Failed to create wallet from private key: {err}")
        }
    }
}