pub(crate) fn increase(
        &mut self,
        dot_id: DotId,
        num_tokens: Multiplicity,
    ) -> Result<(), AcesError> {
        if num_tokens.is_positive() {
            match self.tokens.entry(dot_id) {
                btree_map::Entry::Vacant(entry) => {
                    entry.insert(num_tokens);
                }
                btree_map::Entry::Occupied(mut entry) => {
                    let tokens_before = *entry.get_mut();

                    if tokens_before.is_zero() {
                        *entry.get_mut() = num_tokens;
                    } else if tokens_before.is_finite() {
                        if num_tokens.is_omega() {
                            *entry.get_mut() = num_tokens;
                        } else if let Some(tokens_after) = tokens_before.checked_add(num_tokens) {
                            if tokens_after.is_finite() {
                                *entry.get_mut() = tokens_after;
                            } else {
                                return Err(AcesErrorKind::StateOverflow(
                                    dot_id,
                                    tokens_before,
                                    num_tokens,
                                )
                                .with_context(&self.context))
                            }
                        } else {
                            return Err(AcesErrorKind::StateOverflow(
                                dot_id,
                                tokens_before,
                                num_tokens,
                            )
                            .with_context(&self.context))
                        }
                    }
                }
            }
        }

        Ok(())
    }
/// Note: this routine doesn't check for capacity overflow.
///
/// See also [`FiringComponent::fire()`].
///
/// [`FiringComponent::fire()`]: crate::FiringComponent::fire()
this routine doesn't check for capacity overflow.


this routine doesn ' t check for capacity overflow .
pub(crate) fn increase(
        &mut self,
        dot_id: DotId,
        num_tokens: Multiplicity,
    ) -> Result<(), AcesError> {
        if num_tokens.is_positive() {
            match self.tokens.entry(dot_id) {
                btree_map::Entry::Vacant(entry) => {
                    entry.insert(num_tokens);
                }
                btree_map::Entry::Occupied(mut entry) => {
                    let tokens_before = *entry.get_mut();
                    if tokens_before.is_zero() {
                        *entry.get_mut() = num_tokens;
                    } else if tokens_before.is_finite() {
                        if num_tokens.is_omega() {
                            *entry.get_mut() = num_tokens;
                        } else if let Some(tokens_after) = tokens_before.checked_add(num_tokens) {
                            if tokens_after.is_finite() {
                                *entry.get_mut() = tokens_after;
                            } else {
                                return Err(AcesErrorKind::StateOverflow(
                                    dot_id,
                                    tokens_before,
                                    num_tokens,
                                )
                                .with_context(&self.context))
                            }
                        } else {
                            return Err(AcesErrorKind::StateOverflow(
                                dot_id,
                                tokens_before,
                                num_tokens,
                            )
                            .with_context(&self.context))
                        }
                    }
                }
            }
        }
        Ok(())
    }
pub ( crate ) fn increase ( & mut self , dot_id : DotId , num_tokens : Multiplicity , ) -> Result < ( ) , AcesError > { if num_tokens . is_positive ( ) { match self . tokens . entry ( dot_id ) { btree_map :: Entry :: Vacant ( entry ) => { entry . insert ( num_tokens ) ; } btree_map :: Entry :: Occupied ( mut entry ) => { let tokens_before = * entry . get_mut ( ) ; if tokens_before . is_zero ( ) { * entry . get_mut ( ) = num_tokens ; } else if tokens_before . is_finite ( ) { if num_tokens . is_omega ( ) { * entry . get_mut ( ) = num_tokens ; } else if let Some ( tokens_after ) = tokens_before . checked_add ( num_tokens ) { if tokens_after . is_finite ( ) { * entry . get_mut ( ) = tokens_after ; } else { return Err ( AcesErrorKind :: StateOverflow ( dot_id , tokens_before , num_tokens , ) . with_context ( & self . context ) ) } } else { return Err ( AcesErrorKind :: StateOverflow ( dot_id , tokens_before , num_tokens , ) . with_context ( & self . context ) ) } } } } } Ok ( ( ) ) }
Note: this routine doesn't check for capacity overflow.
Note : this routine doesn ' t check for capacity overflow .
&mut self
dot_id
DotId
num_tokens
Multiplicity
&mut self
dot_id
DotId
num_tokens
Multiplicity