Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
suggested changes to iter_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
MeerKatDev committed Oct 26, 2023
1 parent 0d39d41 commit a26981f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions uniffi_bindgen/src/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,55 +935,55 @@ impl ComponentInterface {
///
/// Documentation comments in the resulting bindings are based on this information.
pub fn attach_documentation(&mut self, mut documentation: uniffi_docs::Documentation) {
for object in self.objects.iter_mut() {
for object in &mut self.objects {
if let Some(doc) = documentation.structures.remove(object.name()) {
let mut methods = doc.methods.clone();

object.documentation = Some(doc);

for constructor in object.constructors.iter_mut() {
for constructor in &mut object.constructors {
if let Some(function) = methods.remove(constructor.name()) {
constructor.documentation = Some(function);
}
}

for method in object.methods.iter_mut() {
for method in &mut object.methods {
if let Some(function) = methods.remove(method.name()) {
method.documentation = Some(function);
}
}
}
}

for (_, record) in self.records.iter_mut() {
for (_, record) in &mut self.records {
if let Some(doc) = documentation.structures.remove(record.name()) {
let mut members = doc.members.clone();

record.documentation = Some(doc);

for field in record.fields.iter_mut() {
for field in &mut record.fields {
if let Some(member) = members.remove(field.name()) {
field.documentation = Some(member);
}
}
}
}

for (_, enum_) in self.enums.iter_mut() {
for (_, enum_) in &mut self.enums {
if let Some(doc) = documentation.structures.remove(enum_.name()) {
let mut members = doc.members.clone();

enum_.documentation = Some(doc);

for variant in enum_.variants.iter_mut() {
for variant in &mut enum_.variants {
if let Some(member) = members.remove(variant.name()) {
variant.documentation = Some(member);
}
}
}
}

for function in self.functions.iter_mut() {
for function in &mut self.functions {
if let Some(doc) = documentation.functions.remove(function.name()) {
function.documentation = Some(doc);
}
Expand Down
2 changes: 1 addition & 1 deletion uniffi_bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub trait BindingsConfig: DeserializeOwned {
pub struct EmptyBindingsConfig;

impl BindingsConfig for EmptyBindingsConfig {
fn update_documentation(&mut self, ci: &mut ComponentInterface, udl_file: &Utf8Path) -> Result<()> { Ok(()) }
fn update_documentation(&mut self, _ci: &mut ComponentInterface, _udl_file: &Utf8Path) -> Result<()> { Ok(()) }
fn update_from_ci(&mut self, _ci: &ComponentInterface) {}
fn update_from_cdylib_name(&mut self, _cdylib_name: &str) {}
fn update_from_dependency_configs(&mut self, _config_map: HashMap<&str, &Self>) {}
Expand Down

0 comments on commit a26981f

Please sign in to comment.