Skip to content

This is a pull request to show Gert how to do one equation in Rust.#64

Closed
simonsantama wants to merge 1 commit intomainfrom
add_equations_chapter59_sfpe
Closed

This is a pull request to show Gert how to do one equation in Rust.#64
simonsantama wants to merge 1 commit intomainfrom
add_equations_chapter59_sfpe

Conversation

@simonsantama
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 30, 2026 13:48
@simonsantama simonsantama deleted the add_equations_chapter59_sfpe branch January 30, 2026 13:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +1 to +7
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)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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
)

Copilot uses AI. Check for mistakes.
@@ -1,2 +1,3 @@
pub mod chapter_14;
pub mod chapter_50;
pub mod chapter_59;
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Create crates/python_api/src/sfpe_handbook/chapter_59/ directory
  2. Add crates/python_api/src/sfpe_handbook/chapter_59/equation_59_4.rs with PyO3 bindings
  3. Add crates/python_api/src/sfpe_handbook/chapter_59.rs module file
  4. Update crates/python_api/src/sfpe_handbook.rs to include pub mod chapter_59; and add it to the module with wrap_pymodule!
  5. Update crates/python_api/docs/api/sfpe-handbook.rst to document the new chapter

See crates/python_api/src/sfpe_handbook/chapter_50/ as a reference implementation.

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant