pub struct LinearTerms<'a> {
pub coeffs: Cow<'a, [(VarId, f64)]>,
pub constant: f64,
}Expand description
Coefficients of a linear expression: sum(coeff * var) + constant.
The coefficient storage borrows directly from an ExprNode::Linear when
possible and owns coefficients that must be synthesized while walking an
expression tree. Call LinearTerms::into_owned before storing extracted
terms beyond the lifetime of their ExprArena.
Fields§
§coeffs: Cow<'a, [(VarId, f64)]>§constant: f64Implementations§
Source§impl<'a> LinearTerms<'a>
impl<'a> LinearTerms<'a>
Sourcepub fn owned(coeffs: Vec<(VarId, f64)>, constant: f64) -> Self
pub fn owned(coeffs: Vec<(VarId, f64)>, constant: f64) -> Self
Construct linear terms with owned coefficient storage.
Sourcepub fn borrowed(coeffs: &'a [(VarId, f64)], constant: f64) -> Self
pub fn borrowed(coeffs: &'a [(VarId, f64)], constant: f64) -> Self
Construct linear terms borrowing coefficient storage.
Sourcepub fn into_owned(self) -> LinearTerms<'static>
pub fn into_owned(self) -> LinearTerms<'static>
Detach these terms from their borrowed source.
This does not allocate when the coefficient storage is already owned.
Trait Implementations§
Source§impl<'a> Clone for LinearTerms<'a>
impl<'a> Clone for LinearTerms<'a>
Source§impl<'a> Debug for LinearTerms<'a>
impl<'a> Debug for LinearTerms<'a>
Auto Trait Implementations§
impl<'a> Freeze for LinearTerms<'a>
impl<'a> RefUnwindSafe for LinearTerms<'a>
impl<'a> Send for LinearTerms<'a>
impl<'a> Sync for LinearTerms<'a>
impl<'a> Unpin for LinearTerms<'a>
impl<'a> UnsafeUnpin for LinearTerms<'a>
impl<'a> UnwindSafe for LinearTerms<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more