From d8d4eac3ad3b867c0e9923b8a6f0dd63379396e7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 22 Dec 2022 20:05:00 +0100 Subject: [PATCH] fix(contract): add setter for MultiBindings' rustfmt (#1948) --- .../ethers-contract-abigen/src/multi.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ethers-contract/ethers-contract-abigen/src/multi.rs b/ethers-contract/ethers-contract-abigen/src/multi.rs index f4bd7837..a0c4a21d 100644 --- a/ethers-contract/ethers-contract-abigen/src/multi.rs +++ b/ethers-contract/ethers-contract-abigen/src/multi.rs @@ -31,6 +31,12 @@ impl std::ops::Deref for MultiAbigen { } } +impl std::ops::DerefMut for MultiAbigen { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abigens + } +} + impl From> for MultiAbigen { fn from(abigens: Vec) -> Self { Self { abigens } @@ -372,6 +378,16 @@ impl MultiBindings { self.expansion.contracts.is_empty() } + /// Specify whether or not to format the code using a locally installed copy + /// of `rustfmt`. + /// + /// Note that in case `rustfmt` does not exist or produces an error, the + /// unformatted code will be used. + pub fn rustfmt(mut self, rustfmt: bool) -> Self { + self.rustfmt = rustfmt; + self + } + fn into_inner(self, single_file: bool) -> MultiBindingsInner { self.expansion.into_bindings(single_file, self.rustfmt) }