borrow of moved value: `project_settings.short_id`
move occurs because `project_settings.short_id` has type `std::string::String`,
which does not implement the `Copy` trait
rustc E0382
lib.rs(30, 21): value moved here
Looks like something in the // ... consumed project_settings.short_id or all of project_settings. There's not enough context for me to guess what's going on beyond that.
if !is_id_valid(&project_settings.short_id) {
// n.b. ^
return Err(ProjectSettingsError::InvalidShortId);
}
if !is_id_valid(&project_settings.full_id) {
// n.b. ^
return Err(ProjectSettingsError::InvalidFullId);
}
// no cloning
Ok(project_settings)
Or if that doesn't work, you could do
// Clone here instead
if !is_id_valid(project_settings.short_id.clone()) {
return Err(ProjectSettingsError::InvalidShortId);
}
if !is_id_valid(project_settings.full_id.clone()) {
return Err(ProjectSettingsError::InvalidFullId);
}
// still no cloning here
Ok(project_settings)
But probably is_id_valid should be rewritten to take a &str instead of a String instead (so that the first suggestion works).
You might also want to read this chapter in the book to learn more about non-Copy data more generally. The error could be rephrased "you tried to use something after you moved it, but you can only do that with types that are Copy... and that type isn't Copy."