From 0a6a990828191c8a91700098f69302fc1aed7a22 Mon Sep 17 00:00:00 2001 From: davhojt Date: Mon, 23 May 2022 11:35:48 +0300 Subject: [PATCH] docs(string_literals): correct grammar --- subjects/string_literals/README.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/subjects/string_literals/README.md b/subjects/string_literals/README.md index 1b876854..a1cc4b05 100644 --- a/subjects/string_literals/README.md +++ b/subjects/string_literals/README.md @@ -4,21 +4,11 @@ Create the following functions: -- `is_empty`, that returns true if a string is empty -- `is_ascii`, that returns true if all characters of a given string is in ASCII range -- `contains`, that returns true if the string contains a pattern given -- `split_at`, that divides a string in two returning a tuple -- `find', that returns the index if the first character of a given string that matches the pattern - -> This exercise will test how many times the **heap is going to be allocated**!\ -> So try your best to allocate the minimum data on the heap! - -### Notions - -- [stack and heap](https://doc.rust-lang.org/1.22.0/book/first-edition/the-stack-and-the-heap.html) -- [Literals](https://doc.rust-lang.org/rust-by-example/primitives/literals.html) - -### Expected Functions +- `is_empty`: that returns `true` if the string is empty. +- `is_ascii`: that returns `true` if all characters are within the ASCII range. +- `contains`: that returns `true` if the string contains the given pattern. +- `split_at`: that divides a string in two returning a tuple. +- `find`: that returns the index if the first character of a given string that matches the pattern. ```rust pub fn is_empty(v: &str) -> bool { @@ -37,6 +27,8 @@ pub fn find(v: &str, pat: char) -> usize { } ``` +> Your heap allocations will be monitored to ensure that you do not make too many allocations, and that your allocations are reasonably sized. + ### Usage Here is a program to test your function @@ -64,3 +56,8 @@ true 1 $ ``` + +### Notions + +- [stack and heap](https://doc.rust-lang.org/1.22.0/book/first-edition/the-stack-and-the-heap.html) +- [Literals](https://doc.rust-lang.org/rust-by-example/primitives/literals.html)