here is some code extract:
impl<K: Kinematic + std::fmt::Debug + Clone> Move<K> for LinearMove {
fn get_trajectory(
&self,
kin: &K,
start_positions: &HashMap<Axis, f32>,
) -> Result<Option<Box<dyn QTrajectory>>> {
let origin = kin.joints_to_pose(&[
start_positions[&Axis(1)],
start_positions[&Axis(2)],
start_positions[&Axis(3)],
start_positions[&Axis(4)],
]);
let new_kin = (*kin).clone();
let traj = Box::new(LinearTrajectory::new(
new_kin,
origin,
self.target,
self.lin_vel,
self.lin_acc,
self.lin_jerk,
self.rot_vel,
self.rot_acc,
self.rot_jerk,
self.rot_dir,
)?);
Ok(Some(traj))
}
}
where new is defined as
impl<K: Kinematic + std::fmt::Debug + Clone> LinearTrajectory<K> {
#[allow(clippy::too_many_arguments)]
pub fn new(
kinematic: K,
mut origin: IsometryMatrix3<f32>,
mut target: IsometryMatrix3<f32>,
.....
It fails to compile with the following error
error[E0310]: the parameter type `K` may not live long enough
--> src/motion_service.rs:168:17
|
168 | Ok(Some(traj))
| ^^^^
| |
| the parameter type `K` must be valid for the static lifetime...
| ...so that the type `K` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
142 | impl<K: Kinematic + std::fmt::Debug + Clone + 'static> Move<K> for LinearMove {
| +++++++++
For more information about this error, try `rustc --explain E0310`.
How is that possible? I cloned the object of type K and passed it a new object that takes ownership of it. What could generate such an error?