Use clone_from in OSDK instead of assigning clones

This commit is contained in:
Zhang Junyang
2024-05-03 22:25:52 +08:00
committed by Tate, Hongliang Tian
parent b4a357a971
commit ee740020d0
5 changed files with 12 additions and 12 deletions

View File

@ -50,7 +50,7 @@ impl Build {
pub fn apply_common_args(&mut self, common_args: &CommonArgs) {
let build_args = &common_args.build_args;
if let Some(profile) = build_args.profile() {
self.profile = profile.clone();
self.profile.clone_from(&profile);
}
self.features.extend(build_args.features.clone());
self.override_configs
@ -67,7 +67,7 @@ impl Build {
impl BuildScheme {
pub fn inherit(&mut self, parent: &Self) {
if self.profile.is_none() {
self.profile = parent.profile.clone();
self.profile.clone_from(&parent.profile);
}
self.features = {
let mut features = parent.features.clone();

View File

@ -60,7 +60,7 @@ impl BootScheme {
init_args
};
if self.initramfs.is_none() {
self.initramfs = from.initramfs.clone();
self.initramfs.clone_from(&from.initramfs);
}
if self.method.is_none() {
self.method = from.method;

View File

@ -43,7 +43,7 @@ impl Default for Grub {
impl GrubScheme {
pub fn inherit(&mut self, from: &Self) {
if self.grub_mkrescue.is_none() {
self.grub_mkrescue = from.grub_mkrescue.clone();
self.grub_mkrescue.clone_from(&from.grub_mkrescue);
}
if self.boot_protocol.is_none() {
self.boot_protocol = from.boot_protocol;

View File

@ -69,17 +69,17 @@ impl Scheme {
if let Some(qemu) = &mut self.qemu {
if let Some(from_qemu) = &from.qemu {
if qemu.args.is_none() {
qemu.args = from_qemu.args.clone();
self.work_dir = from.work_dir.clone();
qemu.args.clone_from(&from_qemu.args);
self.work_dir.clone_from(&from.work_dir);
}
if qemu.path.is_none() {
qemu.path = from_qemu.path.clone();
self.work_dir = from.work_dir.clone();
qemu.path.clone_from(&from_qemu.path);
self.work_dir.clone_from(&from.work_dir);
}
}
} else {
self.qemu = from.qemu.clone();
self.work_dir = from.work_dir.clone();
self.qemu.clone_from(&from.qemu);
self.work_dir.clone_from(&from.work_dir);
}
}
}

View File

@ -53,10 +53,10 @@ impl Qemu {
impl QemuScheme {
pub fn inherit(&mut self, from: &Self) {
if self.args.is_none() {
self.args = from.args.clone();
self.args.clone_from(&from.args);
}
if self.path.is_none() {
self.path = from.path.clone();
self.path.clone_from(&from.path);
}
}