1

How do I print the value of a bool in Rust?

let mut myFalseBool = false; let mut myTrueBool = true; //how do I print out the value of either bool? 

2 Answers 2

3

The same way you print any value:

let foobar = true; println!("{}", foobar); dbg!(foobar); 

This outputs:

true [src/main.rs:4] foobar = true 
Sign up to request clarification or add additional context in comments.

Comments

1

Easy 2023 way:

const IS_KANEKI_GHOUL: bool = true; const IS_ICHIGO_GHOUL: bool = false; println!("{IS_KANEKI_GHOUL}, {IS_ICHIGO_GHOUL}"); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.