if let else -> match
This commit is contained in:
parent
ae7a296c85
commit
a0ad457575
1 changed files with 21 additions and 19 deletions
|
@ -278,17 +278,18 @@ impl Ctx {
|
||||||
let mut has_self_param = false;
|
let mut has_self_param = false;
|
||||||
if let Some(param_list) = func.param_list() {
|
if let Some(param_list) = func.param_list() {
|
||||||
if let Some(self_param) = param_list.self_param() {
|
if let Some(self_param) = param_list.self_param() {
|
||||||
let self_type = if let Some(type_ref) = self_param.ascribed_type() {
|
let self_type = match self_param.ascribed_type() {
|
||||||
TypeRef::from_ast(&self.body_ctx, type_ref)
|
Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref),
|
||||||
} else {
|
None => {
|
||||||
let self_type = TypeRef::Path(name![Self].into());
|
let self_type = TypeRef::Path(name![Self].into());
|
||||||
match self_param.kind() {
|
match self_param.kind() {
|
||||||
ast::SelfParamKind::Owned => self_type,
|
ast::SelfParamKind::Owned => self_type,
|
||||||
ast::SelfParamKind::Ref => {
|
ast::SelfParamKind::Ref => {
|
||||||
TypeRef::Reference(Box::new(self_type), Mutability::Shared)
|
TypeRef::Reference(Box::new(self_type), Mutability::Shared)
|
||||||
}
|
}
|
||||||
ast::SelfParamKind::MutRef => {
|
ast::SelfParamKind::MutRef => {
|
||||||
TypeRef::Reference(Box::new(self_type), Mutability::Mut)
|
TypeRef::Reference(Box::new(self_type), Mutability::Mut)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -583,20 +584,21 @@ impl Ctx {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec<TypeBound> {
|
fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec<TypeBound> {
|
||||||
if let Some(bound_list) = node.type_bound_list() {
|
match node.type_bound_list() {
|
||||||
bound_list.bounds().map(|it| TypeBound::from_ast(&self.body_ctx, it)).collect()
|
Some(bound_list) => {
|
||||||
} else {
|
bound_list.bounds().map(|it| TypeBound::from_ast(&self.body_ctx, it)).collect()
|
||||||
Vec::new()
|
}
|
||||||
|
None => Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_visibility(&self, item: &impl ast::VisibilityOwner) -> RawVisibility {
|
fn lower_visibility(&self, item: &impl ast::VisibilityOwner) -> RawVisibility {
|
||||||
if let Some(vis) = self.forced_visibility.as_ref() {
|
match &self.forced_visibility {
|
||||||
vis.clone()
|
Some(vis) => vis.clone(),
|
||||||
} else {
|
None => RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene),
|
||||||
RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef {
|
fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef {
|
||||||
TypeRef::from_ast(&self.body_ctx, type_ref.clone())
|
TypeRef::from_ast(&self.body_ctx, type_ref.clone())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue