Skip to main content

ObjectiveEvalError

Struct ObjectiveEvalError 

Source
pub struct ObjectiveEvalError { /* private fields */ }
Expand description

A failed objective evaluation, classified by the producer.

§Why this carries a typed source

The classification must be made once, by the code that knows what failed, and then travel unchanged. Before this type carried a source, the boundary was lossy: a caller with a rich typed error in hand had to render it to a String to cross into opt, and any layer that later needed to re-classify the same failure had nothing left to consult but the prose. That can produce a real defect: one error variant may be classified recoverable at the site that can still see its type and fatal at the site that could only see its text, so a trial the optimizer is equipped to survive aborts the entire run. The verdict was carried in prose, and prose is one format! away from silently changing meaning.

recoverable_from and fatal_from attach the originating error so downstream code can downcast_ref back to it instead of re-deriving a classification that was already made.

Implementations§

Source§

impl ObjectiveEvalError

Source

pub fn recoverable(message: impl Into<String>) -> ObjectiveEvalError

A recoverable failure described only by a message.

Source

pub fn fatal(message: impl Into<String>) -> ObjectiveEvalError

A fatal failure described only by a message.

Source

pub fn from_source<E>(kind: ObjectiveEvalKind, source: E) -> ObjectiveEvalError
where E: Error + Send + Sync + 'static,

A failure of the given kind carrying the originating typed error.

The message is the source’s Display; the source itself stays reachable via source_ref / downcast_ref so no later layer has to reconstruct the classification from text.

Source

pub fn recoverable_from<E>(source: E) -> ObjectiveEvalError
where E: Error + Send + Sync + 'static,

Source

pub fn fatal_from<E>(source: E) -> ObjectiveEvalError
where E: Error + Send + Sync + 'static,

Source

pub fn with_context(self, context: impl Display) -> ObjectiveEvalError

Prefix the message, preserving the kind and the typed source.

Use this instead of format!-ing the rendered error into a new ObjectiveEvalError: re-wrapping through a string is exactly what loses the classification.

Source

pub fn kind(&self) -> ObjectiveEvalKind

The producer’s classification.

Source

pub fn is_recoverable(&self) -> bool

true when the solver may back off and continue.

Source

pub fn is_fatal(&self) -> bool

true when the run cannot continue.

Source

pub fn message(&self) -> &str

The message, without the kind prefix Display adds.

Source

pub fn into_message(self) -> String

Consume the error and take its message.

Source

pub fn source_ref(&self) -> Option<&(dyn Error + Send + Sync + 'static)>

The originating error, when one was attached.

Source

pub fn downcast_ref<E>(&self) -> Option<&E>
where E: Error + Send + Sync + 'static,

Recover the producer’s own error type.

This is the mechanism that lets a classification be carried rather than re-derived: a layer that needs to know what failed asks for the type back instead of pattern-matching the prose.

Trait Implementations§

Source§

impl Clone for ObjectiveEvalError

Source§

fn clone(&self) -> ObjectiveEvalError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectiveEvalError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for ObjectiveEvalError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for ObjectiveEvalError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V