Skip to content

Commit c653762

Browse files
committed
Obviate clones by changing Namer type
See: rust-lang/rfcs#1156 https://stackoverflow.com/a/40053651
1 parent 789c63d commit c653762

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tyrga-lib/src/lib.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn test_expand() -> GeneralResult<()> {
164164
Ok(())
165165
}
166166

167-
type Namer = dyn Fn(&dyn fmt::Display) -> GeneralResult<String>;
167+
type Namer<'a> = dyn Fn(&dyn fmt::Display) -> GeneralResult<String> + 'a;
168168
type InsnTriple = (usize, Vec<Instruction>, Vec<Destination>);
169169
type MakeInsnResult = GeneralResult<InsnTriple>;
170170

@@ -956,12 +956,7 @@ fn make_blocks_for_method(class : &ClassFile, method : &MethodInfo, sm : &stack:
956956
}
957957
seen.insert(which.start);
958958

959-
let namer = {
960-
// TODO obviate clones
961-
let class = class.clone();
962-
let method = method.clone();
963-
move |x : &dyn fmt::Display| make_label(&class, &method, &x)
964-
};
959+
let namer = |x : &dyn Display| make_label(&class, &method, x);
965960

966961
let get_constant = get_constant_getter(&class);
967962

0 commit comments

Comments
 (0)