Nonobvious char matching

Hi there!

In short, why the heck is '\n' == '\t'true? That makes absolutely no sense to me.

From the documentation:

Tab is escaped as \t.
Carriage return is escaped as \r.
Line feed is escaped as \n.

This is super weird behavior to me. Can someone explain?
Here's a link to the code in question: Playground

It's not.

fn main() {
    let definitely_false = '\n' == '\t';
    println!("definitely_false is: {:?}", definitely_false);
    assert!(definitely_false, "this is a panic message");


definitely_false is: false
thread 'main' panicked at 'this is a panic message', src/
note: Run with `RUST_BACKTRACE=1` for a backtrace.

You want assert_eq!.

1 Like

rofl well THAT makes a big difference!

Wow, thank you! >.<