Skip to content

Conversation

@starovoid
Copy link
Collaborator

PR provides the following UnionFind methods, that are free from panics:

pub fn try_find(&self, mut x: K) -> Option<K>

pub fn try_find_mut(&mut self, x: K) -> Option<K>

pub fn try_equiv(&self, x: K, y: K) -> Result<bool, K>

pub fn try_union(&mut self, x: K, y: K) -> Result<bool, K>

Some of old methods were rewritten using the try twins with the addition of .unwrap or .expect, for example:

pub fn find(&self, x: K) -> K {
    self.try_find(x).expect("The index is out of bounds")
}

If you consider these changes to be critical & breaking, I will return back the old assertions.

I'm open to discussion!

Copy link
Member

@ABorgna ABorgna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ABorgna
Copy link
Member

ABorgna commented Feb 6, 2025

Error messages are not stable, changing them is not a semver break.

@ABorgna ABorgna merged commit a49bc40 into petgraph:master Feb 6, 2025
7 checks passed
@starovoid starovoid deleted the uf-checked branch February 7, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants