Rust Adventures —Exercism bob

Floriano Victor Peixoto
3 min readMay 9, 2020

Hi there folks!

As you know I’m using the Exercism platform to learn Rust as 2020 goal. Today I´m going to talk about the Bob exercise.

It’s a really simple at first, Bob is a robot that answers you with the following rule:

“Bob answers ‘Sure.’ if you ask him a question, such as “How are you?”.

He answers ‘Whoa, chill out!’ if you YELL AT HIM (in all capitals).

He answers ‘Calm down, I know what I’m doing!’ if you yell a question at him.

He says ‘Fine. Be that way!’ if you address him without actually saying

anything.

He answers ‘Whatever.’ to anything else.”

So I started working on my algorithm and finished my first successful one:

I was not content with the final version. It has a lot of conditionals just to treat the message, it has more exceptions than rules, just for fun I made benchmark with criterion, for the sake of simplicity I just moved the code to the bench file:

--

--