Add rust toolchains

Signed-off-by: Ravago Jones <ravagojones@gmail.com>
Change-Id: I5f36ff152b01bbb628dea45175294cf7f52bb15f
diff --git a/build_tests/BUILD b/build_tests/BUILD
index ca34de2..6a81509 100644
--- a/build_tests/BUILD
+++ b/build_tests/BUILD
@@ -2,6 +2,7 @@
 load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_py_library")
 load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
 load("//tools/build_rules:apache.bzl", "apache_wrapper")
+load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
 
 cc_test(
     name = "gflags_build_test",
@@ -126,3 +127,23 @@
     binary = ":dummy_http_server",
     target_compatible_with = ["@platforms//cpu:x86_64"],
 )
+
+rust_library(
+    name = "hello_lib",
+    srcs = ["hello_lib.rs"],
+    target_compatible_with = ["@platforms//os:linux"],
+)
+
+rust_test(
+    name = "hello_lib_test",
+    srcs = ["hello_lib.rs"],
+    target_compatible_with = ["@platforms//os:linux"],
+    deps = [":hello_lib"],
+)
+
+rust_binary(
+    name = "rust_hello",
+    srcs = ["rust_hello.rs"],
+    target_compatible_with = ["@platforms//os:linux"],
+    deps = [":hello_lib"],
+)
diff --git a/build_tests/hello_lib.rs b/build_tests/hello_lib.rs
new file mode 100644
index 0000000..6374ce6
--- /dev/null
+++ b/build_tests/hello_lib.rs
@@ -0,0 +1,24 @@
+pub struct Greeter {
+        greeting: String,
+}
+
+impl Greeter {
+    pub fn new(greeting: &str) -> Greeter {
+        Greeter { greeting: greeting.to_string(), }
+    }
+
+    pub fn greet(&self, thing: &str) -> String {
+        format!("{} {}", &self.greeting, thing)
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use super::Greeter;
+
+    #[test]
+    fn test_greeting() {
+        let hello = Greeter::new("Hi");
+        assert_eq!("Hi Rust", hello.greet("Rust"));
+    }
+}
diff --git a/build_tests/rust_hello.rs b/build_tests/rust_hello.rs
new file mode 100644
index 0000000..6c6bf9f
--- /dev/null
+++ b/build_tests/rust_hello.rs
@@ -0,0 +1,21 @@
+extern crate hello_lib;
+
+extern "C" {
+    fn sqrt(x: f64) -> f64;
+}
+
+fn main() {
+  let hello = hello_lib::Greeter::new("Hello");
+  println!("{},\n{}", hello.greet("world"), hello.greet("bazel"));
+
+  let mut numbers = Vec::new();
+  for i in 1..=10 {
+      numbers.push(i);
+  }
+  println!("{:?}", numbers);
+
+  let words = vec!["foo", "bar", "baz"];
+  println!("{:?}", words);
+
+  println!("sqrt(4) = {}", unsafe { sqrt(4.0) });
+}