Struct WeightSet
pub struct WeightSet { /* private fields */ }Expand description
A deterministic set of asset weights keyed by asset identifier.
Implementations§
§impl WeightSet
impl WeightSet
pub 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.
pub 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.
pub 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.
pub fn iter(&self) -> Iter<'_, String, PortfolioWeight>
pub fn iter(&self) -> Iter<'_, String, PortfolioWeight>
Iterates over weights in deterministic asset-id order.
Trait Implementations§
§impl<'a> IntoIterator for &'a WeightSet
impl<'a> IntoIterator for &'a WeightSet
§type Item = (&'a String, &'a PortfolioWeight)
type Item = (&'a String, &'a PortfolioWeight)
The type of the elements being iterated over.
§type IntoIter = Iter<'a, String, PortfolioWeight>
type IntoIter = Iter<'a, String, PortfolioWeight>
Which kind of iterator are we turning this into?
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