Closed angelsl closed 7 years ago
IRC is an inherently byte based protocol anyway, so using ascii case insensitive equality is the ideal solution for an IRC library, no need to care about unicode.
I used solution two. As it turns out, there really wasn't enough code for it to be that much worse. The large portion for Command
already used if statements.
RFC 2812 specifies a command to be
There is no mention of case sensitivity of commands.
Currently,
Command::new
and*SubCommand::from_str
only accept uppercase commands.IrcServer::handle_ctcp
also only accepts uppercase commands.As far as I know, all IRC servers now accept commands regardless of case, and most clients will respond to CTCP commands regardless of case.
This would be a trivial fix, but we also want to reduce allocations, so ...
Possible solutions
Match on the
&str
sto_uppercase()
ed.The problem with this is now you get an additional allocation which will be thrown away immediately (unless it can be optimised away?)
Use
eq_ignore_ascii_case
This disregards Unicode case (although there are no commands that are not purely letters), and will be ugly compared to a simple
match
.