Skip to content

Commit

Permalink
Fix readme rust code formatting (getditto#23)
Browse files Browse the repository at this point in the history
Use a format how rustfmt would format for readability.
  • Loading branch information
pickfire authored Feb 22, 2021
1 parent 6617088 commit 729bf8a
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,15 @@ use ::safer_ffi::prelude::*;
#[derive_ReprC]
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub
struct Point {
pub struct Point {
x: f64,
y: f64,
}
/* Export a Rust function to the C world. */
/// Returns the middle point of `[a, b]`.
#[ffi_export]
fn mid_point (
a: &Point,
b: &Point,
) -> Point
{
fn mid_point(a: &Point, b: &Point) -> Point {
Point {
x: (a.x + b.x) / 2.,
y: (a.y + b.y) / 2.,
Expand All @@ -85,16 +80,14 @@ fn mid_point (
/// Pretty-prints a point using Rust's formatting logic.
#[ffi_export]
fn print_point (point: &Point)
{
fn print_point(point: &Point) {
println!("{:?}", point);
}
/// The following test function is necessary for the header generation.
#[::safer_ffi::cfg_headers]
#[test]
fn generate_headers () -> ::std::io::Result<()>
{
fn generate_headers() -> ::std::io::Result<()> {
::safer_ffi::headers::builder()
.to_file("rust_points.h")?
.generate()
Expand Down

0 comments on commit 729bf8a

Please sign in to comment.