find the slope between two points in rust

To find the slope between two points (x1, y1) and (x2, y2), we can use the following Rust code:

main.rs
fn get_slope(x1: f64, y1: f64, x2: f64, y2: f64) -> f64 {
    (y2 - y1) / (x2 - x1)
}
86 chars
4 lines

This function takes in four arguments, the x and y coordinates of the two points. It then subtracts the y coordinates to find the change in y and divides it by the change in x to find the slope.

Note: If the change in x is zero, the slope is undefined.

gistlibby LogSnag