1515//!
1616//! **For developers:**
1717//! - How to add an error to an `enum`? First of all, find a name
18- //! that is not too specific for your current case s.t. it could be used in other
19- //! contexts afterwards as well. Then, find the spot according to your chosen error
20- //! name in a alphanumerically sorted way in the list of supported errors in the doc
21- //! comment and inside the `enum` itself.
22- //! Afterwards, add the error to the list of implemented error
23- //! types in the doc comment of the `enum` with a short description when it is thrown.
24- //! Probably use this description for the doc comment above the implementation of
25- //! error in the `enum`. Then, add `#[error(<error msg>)]` to define the error message
26- //! output once your error is thrown. Below, write down `<error name>(<input>),` to
27- //! define the error with its name and possibly some inputs. The input can be of the
28- //! form [`String`], but also another error, whose conversion must be declared via
29- //! `#[from] OtherError`. It is best to use the existing structure as a guide. For any
30- //! further information, check out the here used [`thiserror`]-crate.
18+ //! that is not too specific for your current case s.t. it could be used in other
19+ //! contexts afterwards as well. Then, find the spot according to your chosen error
20+ //! name in a alphanumerically sorted way in the list of supported errors in the doc
21+ //! comment and inside the `enum` itself.
22+ //! Afterwards, add the error to the list of implemented error
23+ //! types in the doc comment of the `enum` with a short description when it is thrown.
24+ //! Probably use this description for the doc comment above the implementation of
25+ //! error in the `enum`. Then, add `#[error(<error msg>)]` to define the error message
26+ //! output once your error is thrown. Below, write down `<error name>(<input>),` to
27+ //! define the error with its name and possibly some inputs. The input can be of the
28+ //! form [`String`], but also another error, whose conversion must be declared via
29+ //! `#[from] OtherError`. It is best to use the existing structure as a guide. For any
30+ //! further information, check out the here used [`thiserror`]-crate.
3131
3232use std:: ffi:: NulError ;
3333use thiserror:: Error ;
@@ -37,35 +37,35 @@ use thiserror::Error;
3737///
3838/// Implemented error types:
3939/// - [`ConversionError`](MathError::ConversionError) is thrown if a conversion
40- /// between types is not possible.
40+ /// between types is not possible.
4141/// - [`DivisionByZeroError`](MathError::DivisionByZeroError) is thrown if it is
42- /// tried to perform a division by `0`.
42+ /// tried to perform a division by `0`.
4343/// - [`InvalidExponent`](MathError::InvalidExponent) is thrown if an invalid
44- /// exponent is used for a `pow` function.
44+ /// exponent is used for a `pow` function.
4545/// - [`InvalidIntegerInput`](MathError::InvalidIntegerInput) is thrown if an
46- /// integer input is provided as parameter that does not meet the conditions
47- /// of that function.
46+ /// integer input is provided as parameter that does not meet the conditions
47+ /// of that function.
4848/// - [`InvalidInterval`](MathError::InvalidInterval) is thrown if an invalid
49- /// interval, e.g. of negative size, is provided.
49+ /// interval, e.g. of negative size, is provided.
5050/// - [`InvalidModulus`](MathError::InvalidModulus) is thrown if an integer is
51- /// provided, which is smaller than `2`.
51+ /// provided, which is smaller than `2`.
5252/// - [`NulError`](MathError::NulError) is thrown if a [`NulError`] is thrown,
53- /// which currently only happens if an invalid string is given to construct
54- /// a [`CString`](std::ffi::CString).
53+ /// which currently only happens if an invalid string is given to construct
54+ /// a [`CString`](std::ffi::CString).
5555/// - [`MismatchingMatrixDimension`](MathError::MismatchingMatrixDimension) is
56- /// thrown if arithmetic is done with matrices of mismatching dimensions.
56+ /// thrown if arithmetic is done with matrices of mismatching dimensions.
5757/// - [`MismatchingModulus`](MathError::MismatchingModulus) is thrown if any
58- /// function is called on two objects with different modulus where equal
59- /// modulus is required.
58+ /// function is called on two objects with different modulus where equal
59+ /// modulus is required.
6060/// - [`NonPositive`](MathError::NonPositive) is thrown if the function expects
61- /// a positive number, but a number smaller than `1` is provided.
61+ /// a positive number, but a number smaller than `1` is provided.
6262/// - [`NoSquareMatrix`](MathError::NoSquareMatrix) is thrown if a matrix is
63- /// not square.
63+ /// not square.
6464/// - [`OutOfBounds`](MathError::OutOfBounds) is thrown if a provided index
65- /// is not in a desired range.
65+ /// is not in a desired range.
6666/// - [`VectorFunctionCalledOnNonVector`](MathError::VectorFunctionCalledOnNonVector)
67- /// is thrown if a function defined on vectors was called on a matrix instance
68- /// that is not a vector.
67+ /// is thrown if a function defined on vectors was called on a matrix instance
68+ /// that is not a vector.
6969///
7070/// # Examples
7171/// ```
@@ -155,26 +155,26 @@ pub enum MathError {
155155///
156156/// Implemented error types:
157157/// - [`InvalidMatrix`](StringConversionError::InvalidMatrix) is thrown if an
158- /// invalid string input of a matrix is given.
158+ /// invalid string input of a matrix is given.
159159/// - [`InvalidStringToPolyInput`](StringConversionError::InvalidStringToPolyInput)
160- /// is thrown if an invalid string is given to construct a polynomial.
160+ /// is thrown if an invalid string is given to construct a polynomial.
161161/// - [`InvalidStringToPolyMissingWhitespace`](StringConversionError::InvalidStringToPolyMissingWhitespace)
162- /// is thrown if an invalid string is given to construct a polynomial which
163- /// did not contain two whitespaces.
162+ /// is thrown if an invalid string is given to construct a polynomial which
163+ /// did not contain two whitespaces.
164164/// - [`InvalidStringToPolyModulusInput`](StringConversionError::InvalidStringToPolyModulusInput)
165- /// is thrown if an invalid string is given
166- /// to construct a [`PolyOverZq`](crate::integer_mod_q::PolyOverZq), i.e. it is
167- /// not formatted correctly.
165+ /// is thrown if an invalid string is given
166+ /// to construct a [`PolyOverZq`](crate::integer_mod_q::PolyOverZq), i.e. it is
167+ /// not formatted correctly.
168168/// - [`InvalidStringToPolyRingZqInput`](StringConversionError::InvalidStringToPolyRingZqInput)
169- /// is thrown if an invalid string is given
170- /// to construct a [`PolynomialRingZq`](crate::integer_mod_q::PolynomialRingZq), i.e. it is
171- /// not formatted correctly.
169+ /// is thrown if an invalid string is given
170+ /// to construct a [`PolynomialRingZq`](crate::integer_mod_q::PolynomialRingZq), i.e. it is
171+ /// not formatted correctly.
172172/// - [`InvalidStringToQInput`](StringConversionError::InvalidStringToQInput)
173- /// is thrown if an invalid string is given to construct a [`Q`](crate::rational::Q).
173+ /// is thrown if an invalid string is given to construct a [`Q`](crate::rational::Q).
174174/// - [`InvalidStringToZInput`](StringConversionError::InvalidStringToZInput)
175- /// is thrown if an invalid string is given to construct a [`Z`](crate::integer::Z).
175+ /// is thrown if an invalid string is given to construct a [`Z`](crate::integer::Z).
176176/// - [`InvalidStringToZqInput`](StringConversionError::InvalidStringToZqInput)
177- /// is thrown if an invalid string is given to construct a [`Zq`](crate::integer_mod_q::Zq).
177+ /// is thrown if an invalid string is given to construct a [`Zq`](crate::integer_mod_q::Zq).
178178///
179179/// # Examples
180180/// ```
0 commit comments