首页 > 其他 > 详细

Rust 1.7.0 语法基础 标识符(ident)和分隔符的约束

时间:2016-04-19 12:17:11      阅读:326      评论:0      收藏:0      [点我收藏+]

一、标识符

identifier 是标识符,在Rust语法中简写为 ident
ident 是由任意个非空的unicode字符组成。

举例:

在 attribute 语法中,有

meta_item : ident [ ‘=‘ literal  | ‘(‘ meta_seq ‘)‘ ] ? ;

实际使用如下:

#![crate_type = "lib"]
#![allow(dead_code)]
#![feature(intrinsics, lang_items)]
#[test]

上面的 crate_type、allow、feature和test 都是 ident 。

更多参看 Rust 1.7.0 语法基础 attribute

二、分隔符约束

Rust语法中规定了哪些字符不能作为分隔符,而不是规定了哪些字符可以作为分隔符。

约束规则如下:

non_null 表示任意单个unicode字符,但排除 U+0000 (即排除null)
non_eol 表示的是受限的 non_null,排除回车符 U+000A (‘\n’)
non_single_quote 表示的是受限的 non_null 排除单引号 U+0027 (‘)
non_double_quote 表示受限的 non_null 排除了双引号 U+0022 (“)

Rust 1.7.0 语法基础 标识符(ident)和分隔符的约束

原文:http://blog.csdn.net/teamlet/article/details/51182276

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!