Skip to content

Why does the system method take an unmutable reference to self? #15

@thdhondt

Description

@thdhondt

Hi @srenevey ,

First of all, thanks a lot for the work you have put into this crate!
It has been really helpful for getting started with numerical simulation using Rust.

I was wondering if there was a specific reason why the system method in the System trait took an unmutable reference to self:

/// Trait needed to be implemented by the user.
pub trait System<V> {
    fn system(&self, x: f64, y: &V, dy: &mut V);
}

The system I am currently simulating has a small controller built-in.
It is a simple state machine that transitions based on the values inside the State vector.
Unfortunately, I am unable to store this data inside my object implementing the System trait, as I can't modify it via the &self reference.

I am currently a beginner in Rust, so I'm mostly interested in understanding if this was an explicit design decision or just a use case that was not yet covered :).

Thanks in advance for your assistance.

Thomas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions