Skip to content

Generic primitive type parameter with std::marker::Sized bound #100

@WeiPhil

Description

@WeiPhil

Hi,
I am trying to implement something that looks like this for some tuple struct Array :

impl<T: std::marker::Sized> Array<T, U3> {
    pub fn new(x: T, y: T, z: T) -> Array<T, U3> {
        let data: GenericArray<T, U3> = arr![T; x, y, z];
        Array { data }
    }
}

Unfortunately this seems to be impossible for now and the compilers complains that arr![T; x, y, z] has no fixed size at compile-time. It even points me to the impl<T: std::marker::Sized> telling me the parameter nneds to be std::marker::Sized even if it is already bounded.
I suppose there must be a way in the macro to add this condition on T without loss of generality but I'm not familiar with procedural macros myself.
Any tip here?

Cheers,
Philippe

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