This is a pull request to show Gert how to do one equation in Rust.#64
This is a pull request to show Gert how to do one equation in Rust.#64simonsantama wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This is a teaching pull request demonstrating how to implement a single fire engineering equation in Rust. It adds Chapter 59 with equation 59.4, which calculates speed based on three parameters (k, a, d).
Changes:
- Added new Chapter 59 module with equation 59.4 implementing a speed calculation
- Included proper test coverage with one test case validating the calculation
- Applied formatting improvements to existing files (added missing newlines and reformatted function signatures)
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/sfpe_handbook/src/lib.rs | Added chapter_59 module export |
| crates/sfpe_handbook/src/chapter_59.rs | Created chapter module with equation_59_4 export |
| crates/sfpe_handbook/src/chapter_59/equation_59_4.rs | Implemented speed calculation with equation function, LaTeX string representation, and test |
| crates/sfpe_handbook/src/chapter_50/equation_50_17.rs | Reformatted function signature to multi-line parameters |
| crates/sfpe_handbook/src/chapter_50/equation_50_16.rs | Added missing newline at end of file |
| crates/python_api/src/sfpe_handbook/chapter_50/equation_50_20.rs | Added missing newline at end of file |
| crates/python_api/src/sfpe_handbook/chapter_50/equation_50_17.rs | Added missing newline at end of file |
| pub fn speed(k: f64, a: f64, d: f64) -> f64 { | ||
| k - a * k * d | ||
| } | ||
|
|
||
| #[cfg(not(coverage))] | ||
| pub fn speed_equation(s: String, k: String, a: String, d: String) -> String { | ||
| format!("{} = {} - {} \\cdot {} \\cdot {}", s, k, a, k, d) |
There was a problem hiding this comment.
The function parameters k, a, and d use single-letter names without documentation. While the Rust domain crates don't require docstrings, descriptive parameter names would improve code readability. Consider using more descriptive names like free_speed, coefficient, and density (or whatever these parameters represent in the context of equation 59.4).
| pub fn speed(k: f64, a: f64, d: f64) -> f64 { | |
| k - a * k * d | |
| } | |
| #[cfg(not(coverage))] | |
| pub fn speed_equation(s: String, k: String, a: String, d: String) -> String { | |
| format!("{} = {} - {} \\cdot {} \\cdot {}", s, k, a, k, d) | |
| pub fn speed(free_speed: f64, coefficient: f64, density: f64) -> f64 { | |
| free_speed - coefficient * free_speed * density | |
| } | |
| #[cfg(not(coverage))] | |
| pub fn speed_equation( | |
| result_symbol: String, | |
| free_speed_symbol: String, | |
| coefficient_symbol: String, | |
| density_symbol: String, | |
| ) -> String { | |
| format!( | |
| "{} = {} - {} \\cdot {} \\cdot {}", | |
| result_symbol, free_speed_symbol, coefficient_symbol, free_speed_symbol, density_symbol | |
| ) |
| @@ -1,2 +1,3 @@ | |||
| pub mod chapter_14; | |||
| pub mod chapter_50; | |||
| pub mod chapter_59; | |||
There was a problem hiding this comment.
Chapter 59 is missing Python bindings. To make this equation accessible from Python (consistent with other chapters like chapter_14 and chapter_50), you need to:
- Create
crates/python_api/src/sfpe_handbook/chapter_59/directory - Add
crates/python_api/src/sfpe_handbook/chapter_59/equation_59_4.rswith PyO3 bindings - Add
crates/python_api/src/sfpe_handbook/chapter_59.rsmodule file - Update
crates/python_api/src/sfpe_handbook.rsto includepub mod chapter_59;and add it to the module withwrap_pymodule! - Update
crates/python_api/docs/api/sfpe-handbook.rstto document the new chapter
See crates/python_api/src/sfpe_handbook/chapter_50/ as a reference implementation.
No description provided.