You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you create a hierarchy you could potentially delete the selected lower levels from a higher level. For example you select (Model(0), Chain("A"), Residue(123), Conformer("ALA"), Atom("CA", 450, "C")) and then use chain.remove_atoms_by(|a| a.element() == "C") this would delete the selected atom, and would cause undefined behaviour when the atom is used afterwards.
The proposal is to create a trait with all safe functions for each level and make the levels implement it. The hierarchies can then return a trait object instead of the struct which would limit the use of the unsound functions. The unsound functions are all deleting functions and adding/inserting has to be checked thoroughly for potential issues. Any function that returns mut references to lower levels in the hierarchy also has to have a safe counterpart returning a Trait object.
Unsound:
Methods removing items below
Methods returning a &mut to an item in any level below?
Sort?
Extend (and join)?
Add lower level item? (what if this triggers a reallocation of the inner Vec?)
The text was updated successfully, but these errors were encountered:
If you create a hierarchy you could potentially delete the selected lower levels from a higher level. For example you select (Model(0), Chain("A"), Residue(123), Conformer("ALA"), Atom("CA", 450, "C")) and then use
chain.remove_atoms_by(|a| a.element() == "C")
this would delete the selected atom, and would cause undefined behaviour when the atom is used afterwards.The proposal is to create a trait with all safe functions for each level and make the levels implement it. The hierarchies can then return a trait object instead of the struct which would limit the use of the unsound functions. The unsound functions are all deleting functions and adding/inserting has to be checked thoroughly for potential issues. Any function that returns mut references to lower levels in the hierarchy also has to have a safe counterpart returning a Trait object.
Unsound:
&mut
to an item in any level below?The text was updated successfully, but these errors were encountered: