The relevant issue for this is https://github.com/mozilla/rust/issues/4334.

-Kevin

On Jan 15, 2014, at 7:26 AM, Michael Neumann <[email protected]> wrote:

> 
> Am 15.01.2014 16:23, schrieb Evan G:
>> I'm not weighing in on whether this is something rust should do or not, but 
>> we could mimic the 16i, 10u numeric literal system to achieve this in 
>> syntax. An ascii literal would have a suffix, for example 'x'a or 'x'u to 
>> explicitly specify unicode (which would still be the default). This could 
>> probably work for string literals too.
> 
> Something like 'x'a would be very nice to have!
> 
> Regards,
> 
>   Michael
> 
>> 
>> 
>> On Wed, Jan 15, 2014 at 8:37 AM, Michael Neumann <[email protected]> wrote:
>> Hi,
>> 
>> There are lots of protocols based on ASCII character representation. In 
>> Rust, the natural way to represent them is
>> by an u8 literal (optionally wrapped within std::ascii::Ascii).
>> What I am missing is a simple way to represent those literals in code. What 
>> I am doing most of the time is:
>> 
>>     fn read_char() -> Option<char> {
>>        match io.read_byte() {
>>          Some(b) => Some(b as char),
>>          None => None
>>       }
>>     }
>> 
>> And then use character literals in pattern matching. What I'd highly prefer 
>> is a way to directly repesent ASCII characters
>> in the code, like:
>> 
>>     match io.read_byte().unwrap {
>>         'c'_ascii => ....
>>        ....
>>     }
>> 
>> If macros would work in patterns, something like:
>> 
>>    match ... {
>>        ascii!('a') => ...
>>    }
>> 
>> would work for me too. Ideally that would work with range patterns as well, 
>> but of course an ascii_range!() macro would
>> do the same.
>> 
>> Is this useful to anyone?
>> 
>> Regards,
>> 
>>     Michael
>> _______________________________________________
>> Rust-dev mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/rust-dev
>> 
> 
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to