|
@@ -89,7 +89,7 @@ impl Context {
|
|
|
pub(crate) fn is_constructor_function(&self) -> bool {
|
|
pub(crate) fn is_constructor_function(&self) -> bool {
|
|
|
self.function
|
|
self.function
|
|
|
.as_ref()
|
|
.as_ref()
|
|
|
- .map_or(false, |f| matches!(f.ty, FunctionTy::Constructor))
|
|
|
|
|
|
|
+ .is_some_and(|f| matches!(f.ty, FunctionTy::Constructor))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -348,7 +348,7 @@ impl<'a, W: Write> Formatter<'a, W> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
self.find_next_line(start_from)
|
|
self.find_next_line(start_from)
|
|
|
- .map_or(false, |loc| loc >= end_at)
|
|
|
|
|
|
|
+ .is_some_and(|loc| loc >= end_at)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -549,7 +549,7 @@ impl<'a, W: Write> Formatter<'a, W> {
|
|
|
fn write_doc_block_line(&mut self, comment: &CommentWithMetadata, line: &str) -> Result<()> {
|
|
fn write_doc_block_line(&mut self, comment: &CommentWithMetadata, line: &str) -> Result<()> {
|
|
|
if line.trim().starts_with('*') {
|
|
if line.trim().starts_with('*') {
|
|
|
let line = line.trim().trim_start_matches('*');
|
|
let line = line.trim().trim_start_matches('*');
|
|
|
- let needs_space = line.chars().next().map_or(false, |ch| !ch.is_whitespace());
|
|
|
|
|
|
|
+ let needs_space = line.chars().next().is_some_and(|ch| !ch.is_whitespace());
|
|
|
write!(self.buf(), " *{}", if needs_space { " " } else { "" })?;
|
|
write!(self.buf(), " *{}", if needs_space { " " } else { "" })?;
|
|
|
self.write_comment_line(comment, line)?;
|
|
self.write_comment_line(comment, line)?;
|
|
|
self.write_whitespace_separator(true)?;
|
|
self.write_whitespace_separator(true)?;
|
|
@@ -1797,7 +1797,7 @@ impl<'a, W: Write> Formatter<'a, W> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Traverse the Solidity Parse Tree and write to the code formatter
|
|
// Traverse the Solidity Parse Tree and write to the code formatter
|
|
|
-impl<'a, W: Write> Visitor for Formatter<'a, W> {
|
|
|
|
|
|
|
+impl<W: Write> Visitor for Formatter<'_, W> {
|
|
|
type Error = FormatterError;
|
|
type Error = FormatterError;
|
|
|
|
|
|
|
|
#[instrument(name = "source", skip(self))]
|
|
#[instrument(name = "source", skip(self))]
|
|
@@ -1862,7 +1862,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
|
|
|
)?;
|
|
)?;
|
|
|
|
|
|
|
|
// EOF newline
|
|
// EOF newline
|
|
|
- if self.last_char().map_or(true, |char| char != '\n') {
|
|
|
|
|
|
|
+ if self.last_char() != Some('\n') {
|
|
|
writeln!(self.buf())?;
|
|
writeln!(self.buf())?;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -3268,7 +3268,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
|
|
|
|
|
|
|
|
// we can however check if the contract `is` the `base`, this however also does
|
|
// we can however check if the contract `is` the `base`, this however also does
|
|
|
// not cover all cases
|
|
// not cover all cases
|
|
|
- let is_contract_base = self.context.contract.as_ref().map_or(false, |contract| {
|
|
|
|
|
|
|
+ let is_contract_base = self.context.contract.as_ref().is_some_and(|contract| {
|
|
|
contract.base.iter().any(|contract_base| {
|
|
contract.base.iter().any(|contract_base| {
|
|
|
contract_base
|
|
contract_base
|
|
|
.name
|
|
.name
|
|
@@ -3292,7 +3292,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
|
|
|
.content
|
|
.content
|
|
|
.chars()
|
|
.chars()
|
|
|
.next()
|
|
.next()
|
|
|
- .map_or(false, |c| c.is_lowercase());
|
|
|
|
|
|
|
+ .is_some_and(|c| c.is_lowercase());
|
|
|
if is_lowercase && base_or_modifier.content.ends_with("()") {
|
|
if is_lowercase && base_or_modifier.content.ends_with("()") {
|
|
|
base_or_modifier
|
|
base_or_modifier
|
|
|
.content
|
|
.content
|
|
@@ -3904,14 +3904,14 @@ struct Transaction<'f, 'a, W> {
|
|
|
comments: Comments,
|
|
comments: Comments,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-impl<'f, 'a, W> std::ops::Deref for Transaction<'f, 'a, W> {
|
|
|
|
|
|
|
+impl<'a, W> std::ops::Deref for Transaction<'_, 'a, W> {
|
|
|
type Target = Formatter<'a, W>;
|
|
type Target = Formatter<'a, W>;
|
|
|
fn deref(&self) -> &Self::Target {
|
|
fn deref(&self) -> &Self::Target {
|
|
|
self.fmt
|
|
self.fmt
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-impl<'f, 'a, W> std::ops::DerefMut for Transaction<'f, 'a, W> {
|
|
|
|
|
|
|
+impl<W> std::ops::DerefMut for Transaction<'_, '_, W> {
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
|
self.fmt
|
|
self.fmt
|
|
|
}
|
|
}
|