🚧 Doc & code tweaks
This commit is contained in:
parent
fea6c2f69e
commit
c1e641723b
12 changed files with 79 additions and 53 deletions
|
|
@ -44,7 +44,7 @@ impl fmt::Display for ParamError {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ParamError::NotFound => write!(f, "Parameter not found"),
|
||||
ParamError::ParseError(e) => write!(f, "Parse error: {}", e),
|
||||
ParamError::ParseError(e) => write!(f, "Parse error: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -180,22 +180,21 @@ impl Context {
|
|||
// Context EXTRAS.
|
||||
|
||||
pub fn required_id<T>(&mut self, id: Option<String>) -> String {
|
||||
match id {
|
||||
Some(id) => id,
|
||||
None => {
|
||||
let prefix = TypeInfo::ShortName
|
||||
.of::<T>()
|
||||
.trim()
|
||||
.replace(' ', "_")
|
||||
.to_lowercase();
|
||||
let prefix = if prefix.is_empty() {
|
||||
"prefix".to_owned()
|
||||
} else {
|
||||
prefix
|
||||
};
|
||||
self.id_counter += 1;
|
||||
concat_string!(prefix, "-", self.id_counter.to_string())
|
||||
}
|
||||
if let Some(id) = id {
|
||||
id
|
||||
} else {
|
||||
let prefix = TypeInfo::ShortName
|
||||
.of::<T>()
|
||||
.trim()
|
||||
.replace(' ', "_")
|
||||
.to_lowercase();
|
||||
let prefix = if prefix.is_empty() {
|
||||
"prefix".to_owned()
|
||||
} else {
|
||||
prefix
|
||||
};
|
||||
self.id_counter += 1;
|
||||
concat_string!(prefix, "-", self.id_counter.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ fn add_to_enabled(list: &mut Vec<PackageRef>, package: PackageRef) {
|
|||
// Reverse dependencies to add them in correct order (dependencies first).
|
||||
let mut dependencies = package.dependencies();
|
||||
dependencies.reverse();
|
||||
for d in dependencies.iter() {
|
||||
for d in &dependencies {
|
||||
add_to_enabled(list, *d);
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ fn add_to_enabled(list: &mut Vec<PackageRef>, package: PackageRef) {
|
|||
|
||||
fn add_to_dropped(list: &mut Vec<PackageRef>, package: PackageRef) {
|
||||
// Iterate through packages recommended to be dropped.
|
||||
for d in package.drop_packages().iter() {
|
||||
for d in &package.drop_packages() {
|
||||
// Check if the package is not already in the dropped list.
|
||||
if !list.iter().any(|p| p.type_id() == d.type_id()) {
|
||||
// Check if the package is currently enabled. If so, log a warning.
|
||||
|
|
@ -103,7 +103,7 @@ fn add_to_dropped(list: &mut Vec<PackageRef>, package: PackageRef) {
|
|||
trace::debug!("Package \"{}\" dropped", d.short_name());
|
||||
// Recursively add the dependencies of the dropped package to the dropped list.
|
||||
// This ensures that all dependencies are also considered for dropping.
|
||||
for dependency in package.dependencies().iter() {
|
||||
for dependency in &package.dependencies() {
|
||||
add_to_dropped(list, *dependency);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue