-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
enhancementNew feature or requestNew feature or requestprio: low⏭️ breaking changeBreaking change, will require an increment of the major version number. E.g: 0.3.0 -> 0.4.0Breaking change, will require an increment of the major version number. E.g: 0.3.0 -> 0.4.0
Description
I find the amount of polynomial.degree() as usize in our codebase concerning, especially since .degree() returns an isize. This can cause some very funny behavior. I suggest we express a polynomial's degree as an
enum Degree {
Positive(usize), // placeholder name, suggestions welcome
NegativeInfinity,
}and provide convenience methods as we see fit. For example, a common pattern is to panic! if the degree is NegativeInfinity (currently -1), which could be expressed through:
impl Polynomial {
/// # Panics
///
/// Panics if `self` is the zero polynomial.
fn positive_degree(&self) -> usize {
let Degree::Positive(degree) = self.degree() else {
panic!("you messed up");
}
degree
}
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestprio: low⏭️ breaking changeBreaking change, will require an increment of the major version number. E.g: 0.3.0 -> 0.4.0Breaking change, will require an increment of the major version number. E.g: 0.3.0 -> 0.4.0