![](/img/trans.png)
[英]How to use a C typedef struct and functions with that struct from Rust?
[英]How to use variables declared inside a struct from within a struct in Rust?
struct Parser;
impl Parser {
const ALPHABETS_UPPERCASE: [char; 26] = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn get_alphabet(&self) {
self::..
}
}
如何訪問get_alphabet
function 中的ALPHABETS_UPPERCASE
?
Self::ALPHABET_UPPERCASE
(而不是self
)因為這個常量在Parser
中作為一個整體而不是一個特殊的實例發生。
見這里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.