[−][src]Struct debtsolver::Ledger
Represents a zero-sum ledger which tracks the current state of who owes money, and who is owed money. The sum of all balances must always add up to zero, since each debtor has an equivalent creditor.
Methods
impl Ledger
[src]
pub fn new() -> Ledger
[src]
Creates a new Ledger
pub fn add_transaction(&mut self, transaction: Transaction)
[src]
Accepts a transaction and updates debtor and creditor balances in the ledger.
pub fn settle(&mut self, group_size: usize) -> Vec<Transaction>
[src]
Returns the smallest possible set of transactions that will resolve all debts. This ranges between n/2 (best case) and n-1 (worst case), where n is the number of debtors and creditors.
pub fn to_vector(&self) -> Vec<(String, i32)>
[src]
Trait Implementations
Auto Trait Implementations
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnwindSafe for Ledger
impl RefUnwindSafe for Ledger
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,