I am so confused who is the weak and who is the strict?

these keywords are added in rust 2018 they are listed under the strict keywords
but they can be used as weak keywords

rs18:
async
await
dyn

and this one the docs said it is a weak keyword

'static

but cannot be used as a weak keyword

please share code in code blocks, with errors in code blocks as well if useful.

this playground link shows that the code you said works does not work, as early as edition 2018. either you did not save properly or were on edition 2015.

'static is indeed a weak keyword, and can be used everywhere a weak keyword can be used. but 'static begins with ', so it cannot be used as an identifier, just like 'blah can't.

static, ofc, is a strict keyword

so what you are saying is that 'static is a weak keyword but cannot be used as an identifier because of the apostrophe and static alone is a strict keyword ?

Exactly, 'static is a weak keyword and static is a strict keyword. Identifiers (in this case a variable name) cannot contain apostrophes, so of course 'static is not a valid name for a variable.

When the rust reference says that 'static is a weak keyword, it doesn't mean that you can name a variable that way. It means that you can use 'atatic as if it was not a keyword, and where can you use names that start with an apostrophe? Only in loop labels or in lifetimes. So, this code will compile just fine.

fn main() {
    'static: for i in 0..5 {
        for j in 0..5 {
            println!("{}", i + j);
            if i + j == 5 {
                break 'static;
            }
        }
    }
}
1 Like

oky hhh i get it now it looks silly to me now but i wonder couldn't they make it possible !! well i can just ignore this i mean the reason why apostrophe cannot be accepted in identifiers names while the rust team could make it possible just wondering

1 Like

Allowing apostrophes in variable names would be confusing, because you don't expect a random symbol mid-name

1 Like

i see nice thanks for the comments

1 Like