Skip to content

Allow unsafe statements #12261

Closed
Closed
@lexs

Description

@lexs

When writing a lot of unsafe code you often find yourself having to make just some parts of your functions unsafe, however the requirement to use unsafe blocks often makes it nicer to just wrap the function body in unsafe {}.

I want to propose allowing bracketless unsafe for making a single expression unsafe, for example retrieving a global variable require code like this:

let a = unsafe { global.get() };

This could be rewritten to:

let a = unsafe global.get();

It also becomes usefule when matching on globals:

match unsafe { global } {
    ...
}
// vs
match unsafe global {
    ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions