Skip to content

Borrowing static array that contains another static array represented by literal doesn't work when expressed inline #54224

Closed
@pepyakin

Description

@pepyakin

Why does this work:

use std::borrow::Cow;

pub const X: [u8; 3] = *b"ABC";
pub const Y: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[X]);

but this doesn't?

use std::borrow::Cow;

pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]);

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