From 0e05964fff11e3add0937e8288ebd3ec33b53fd0 Mon Sep 17 00:00:00 2001 From: Jordan Gong Date: Tue, 4 Aug 2020 08:53:28 +0800 Subject: Say hello --- hello-rust/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 hello-rust/src/main.rs (limited to 'hello-rust/src/main.rs') diff --git a/hello-rust/src/main.rs b/hello-rust/src/main.rs new file mode 100644 index 0000000..c6a8c27 --- /dev/null +++ b/hello-rust/src/main.rs @@ -0,0 +1,11 @@ +use ferris_says::say; +use std::io::{stdout, BufWriter}; + +fn main() { + let stdout = stdout(); + let message = String::from("Hello fellow Rustaceans!"); + let width = message.chars().count(); + + let mut writer = BufWriter::new(stdout.lock()); + say(message.as_bytes(), width, &mut writer).unwrap(); +} -- cgit v1.2.3