pub struct WeightSet { /* private fields */ }Expand description
A deterministic set of asset weights keyed by asset identifier.
Implementations§
Source§impl WeightSet
impl WeightSet
Sourcepub fn from_asset_weights(
weights: impl IntoIterator<Item = AssetWeight>,
) -> Result<WeightSet, PortfolioWeightError>
pub fn from_asset_weights( weights: impl IntoIterator<Item = AssetWeight>, ) -> Result<WeightSet, PortfolioWeightError>
Creates a weight set from asset weights.
§Errors
Returns PortfolioWeightError::DuplicateAssetId when an asset appears more than once.
Sourcepub fn insert(
&mut self,
asset_weight: AssetWeight,
) -> Result<(), PortfolioWeightError>
pub fn insert( &mut self, asset_weight: AssetWeight, ) -> Result<(), PortfolioWeightError>
Inserts an asset weight.
§Errors
Returns PortfolioWeightError::DuplicateAssetId when the asset already exists.
Sourcepub fn is_approximately_fully_invested(
&self,
tolerance: f64,
) -> Result<bool, PortfolioWeightError>
pub fn is_approximately_fully_invested( &self, tolerance: f64, ) -> Result<bool, PortfolioWeightError>
Checks whether weights sum approximately to 1.0 within tolerance.
§Errors
Returns PortfolioWeightError::NonFiniteTolerance or
PortfolioWeightError::NegativeTolerance when tolerance is invalid.
Sourcepub fn iter(&self) -> Iter<'_, String, PortfolioWeight>
pub fn iter(&self) -> Iter<'_, String, PortfolioWeight>
Iterates over weights in deterministic asset-id order.
Trait Implementations§
Source§impl<'a> IntoIterator for &'a WeightSet
impl<'a> IntoIterator for &'a WeightSet
impl StructuralPartialEq for WeightSet
Auto Trait Implementations§
impl Freeze for WeightSet
impl RefUnwindSafe for WeightSet
impl Send for WeightSet
impl Sync for WeightSet
impl Unpin for WeightSet
impl UnsafeUnpin for WeightSet
impl UnwindSafe for WeightSet
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