Use Option::is_some_and
and Result::is_ok_and
in the compiler
This commit is contained in:
parent
70db836922
commit
fb0f74a8c9
87 changed files with 148 additions and 158 deletions
|
@ -2391,10 +2391,10 @@ pub struct FnDecl {
|
|||
|
||||
impl FnDecl {
|
||||
pub fn has_self(&self) -> bool {
|
||||
self.inputs.get(0).map_or(false, Param::is_self)
|
||||
self.inputs.get(0).is_some_and(Param::is_self)
|
||||
}
|
||||
pub fn c_variadic(&self) -> bool {
|
||||
self.inputs.last().map_or(false, |arg| matches!(arg.ty.kind, TyKind::CVarArgs))
|
||||
self.inputs.last().is_some_and(|arg| matches!(arg.ty.kind, TyKind::CVarArgs))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ impl Attribute {
|
|||
}
|
||||
|
||||
pub fn may_have_doc_links(&self) -> bool {
|
||||
self.doc_str().map_or(false, |s| comments::may_have_doc_links(s.as_str()))
|
||||
self.doc_str().is_some_and(|s| comments::may_have_doc_links(s.as_str()))
|
||||
}
|
||||
|
||||
pub fn is_proc_macro_attr(&self) -> bool {
|
||||
|
@ -441,12 +441,12 @@ impl NestedMetaItem {
|
|||
|
||||
/// Returns `true` if this list item is a MetaItem with a name of `name`.
|
||||
pub fn has_name(&self, name: Symbol) -> bool {
|
||||
self.meta_item().map_or(false, |meta_item| meta_item.has_name(name))
|
||||
self.meta_item().is_some_and(|meta_item| meta_item.has_name(name))
|
||||
}
|
||||
|
||||
/// Returns `true` if `self` is a `MetaItem` and the meta item is a word.
|
||||
pub fn is_word(&self) -> bool {
|
||||
self.meta_item().map_or(false, |meta_item| meta_item.is_word())
|
||||
self.meta_item().is_some_and(|meta_item| meta_item.is_word())
|
||||
}
|
||||
|
||||
/// Gets a list of inner meta items from a list `MetaItem` type.
|
||||
|
|
|
@ -607,7 +607,7 @@ impl Token {
|
|||
/// Returns `true` if the token is an identifier whose name is the given
|
||||
/// string slice.
|
||||
pub fn is_ident_named(&self, name: Symbol) -> bool {
|
||||
self.ident().map_or(false, |(ident, _)| ident.name == name)
|
||||
self.ident().is_some_and(|(ident, _)| ident.name == name)
|
||||
}
|
||||
|
||||
/// Returns `true` if the token is an interpolated path.
|
||||
|
|
|
@ -392,8 +392,7 @@ fn integer_lit(symbol: Symbol, suffix: Option<Symbol>) -> Result<LitKind, LitErr
|
|||
// Small bases are lexed as if they were base 10, e.g, the string
|
||||
// might be `0b10201`. This will cause the conversion above to fail,
|
||||
// but these kinds of errors are already reported by the lexer.
|
||||
let from_lexer =
|
||||
base < 10 && s.chars().any(|c| c.to_digit(10).map_or(false, |d| d >= base));
|
||||
let from_lexer = base < 10 && s.chars().any(|c| c.to_digit(10).is_some_and(|d| d >= base));
|
||||
if from_lexer { LitError::LexerError } else { LitError::IntTooLarge(base) }
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue