Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

built out rough input parser taking basic yes no commands, as well as… #13

Merged
merged 1 commit into from
Aug 22, 2022

Conversation

KyleFrisbie
Copy link
Owner

… the command move

@KyleFrisbie KyleFrisbie linked an issue Aug 21, 2022 that may be closed by this pull request
@KyleFrisbie KyleFrisbie removed a link to an issue Aug 21, 2022
@KyleFrisbie
Copy link
Owner Author

This is a start to the issue for #3 . I felt that by bringing in a starting place for I/O, it might help get the juices flowing for everyone. Feel free to change the implementation. This is certainly incomplete.

pub static VALID_NEGATIVE_RESPONSES: [&str; 2] = ["no", "n"];
static VALID_ACTIONS: [&str; 1] = ["move"];

pub fn get_valid_response(input: String) -> (String, bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are awesome helper funcs, I like the way it's organized

mod story_manager;
use story_manager::{introduction, tutorial};
mod user_command;

fn main() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love how this is organized and modular too 👌

@mikelbrierly mikelbrierly merged commit ee87113 into main Aug 22, 2022

let mut buffer = String::with_capacity(2048);
// Lock our standard input to eliminate synchronization overhead (unlocks when dropped)
let mut stdin = io::stdin().lock();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about this, and maybe I just haven't learned enough about Rust yet, but -

line 40 defines an immutable variable, right? but then line 44 defines the same variable name, but mutable, so is this still a "shadow" variable since the first one was supposed to be immutable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants