aboutsummaryrefslogtreecommitdiff
path: root/src/transform.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-19 09:50:34 +0100
committerMartin Fischer <martin@push-f.com>2021-11-19 09:51:58 +0100
commiteb686879fdd7cde5d09837c202ebd25c9c9889a6 (patch)
treeec5388cd7e86513ed01dd5a89527fc44c4576777 /src/transform.rs
parent8e99d7bd6ebf9d1981667799f43cf45f682e1fff (diff)
refactor: forward type param transforms as HashMap
Diffstat (limited to 'src/transform.rs')
-rw-r--r--src/transform.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/transform.rs b/src/transform.rs
index 4fc22f5..ec2f3a6 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -12,7 +12,7 @@ use crate::{
};
#[derive(Default)]
-pub struct AssocTypeConversions<'a>(pub HashMap<&'a Ident, &'a Type>);
+pub struct AssocTypeConversions<'a>(pub HashMap<Ident, &'a Type>);
pub enum TransformError {
UnconvertibleAssocType(Span),
@@ -36,7 +36,7 @@ impl AssocTypeConversions<'_> {
let ident = &path.segments.last().unwrap().ident;
*type_ = (*self
.0
- .get(&ident)
+ .get(ident)
.ok_or_else(|| TransformError::UnconvertibleAssocType(ident.span()))?)
.clone();
return Ok(TypeTransform::Into);
@@ -100,10 +100,10 @@ impl AssocTypeConversions<'_> {
}
}
-pub fn dynamize_function_bounds<'a>(
- generics: &'a mut Generics,
- assoc_type_conversions: &AssocTypeConversions<'a>,
-) -> Result<HashMap<&'a Ident, Vec<TypeTransform>>, (Span, MethodParseError)> {
+pub fn dynamize_function_bounds(
+ generics: &mut Generics,
+ assoc_type_conversions: &AssocTypeConversions,
+) -> Result<HashMap<Ident, Vec<TypeTransform>>, (Span, MethodParseError)> {
let mut type_param_transforms = HashMap::new();
for generic_param in &mut generics.params {
@@ -139,7 +139,8 @@ pub fn dynamize_function_bounds<'a>(
}
}
if transforms.iter().any(|t| !matches!(t, TypeTransform::NoOp)) {
- type_param_transforms.insert(&type_param.ident, transforms);
+ type_param_transforms
+ .insert(type_param.ident.clone(), transforms);
}
}
}