Skip to content

The ultimate safety #30

@turalcar

Description

@turalcar

There is a way to make this truly safe (I won't spoil this for you)

fn translate<'a, T>(_: &'static &'a (), x: &'a T) -> &'static T {
    x
}

trait Witness<'a> {
    fn extend<T>(self, x: &'a T) -> &'static T;
}

impl<'a> Witness<'a> for &'static () {
    fn extend<T>(self, x: &'a T) -> &'static T {
        translate(&self, x)
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions