From 474c0e9f865e78138b34f8049c5d6e285fc5f362 Mon Sep 17 00:00:00 2001 From: Abdelilah Khossan <49311230+akhossanX@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:50:45 +0100 Subject: [PATCH] docs(rust piscine): Add invert_sentence optional exercise subject (#2221) * docs(rust piscine): Add invert_sentence optional exercise subject * docs(rust piscine): Update invert_sentence subject * docs(rust piscine): fix typo in invert_sentence exercise --- subjects/invert_sentence/README.md | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 subjects/invert_sentence/README.md diff --git a/subjects/invert_sentence/README.md b/subjects/invert_sentence/README.md new file mode 100644 index 00000000..90856384 --- /dev/null +++ b/subjects/invert_sentence/README.md @@ -0,0 +1,38 @@ +## invert_sentence + +### Instructions + +Write a function called `invert_sentence` that takes a string as input and returns the words in the string in reverse order. +In other words, the function should take a sentence as input and return a new sentence with the words reversed. + +### Expected Function + +```rust +pub fn invert_sentence(string: &str) -> String { + // Your code goes here +} +``` + +### Usage + +Here is a possible runner to test your function : + +```rust +use invert_sentence::invert_sentence; + +fn main() { + println!("{}", invert_sentence("Rust is Awesome")); + println!("{}", invert_sentence(" word1 word2 ")); + println!("{}", invert_sentence("Hello, World!")); +} +``` + +And its output: + +```console +$ cargo run | cat -e +Awesome is Rust$ + word2 word1 $ +World! Hello,$ +$ +```