Reformat rust code using 1.40 rustfmt and fail build if rustfmt fails (#2339)

diff --git a/rust-toolchain b/rust-toolchain
new file mode 100644
index 0000000..32b7211
--- /dev/null
+++ b/rust-toolchain
@@ -0,0 +1 @@
+1.40.0