Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is this + (plus) in trait bounds?

Explain this line of Rust code (what is +?):

pub struct BlinkAlloc<A: Allocator = +Global> {

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I think you are looking at this:

pub struct BlinkAlloc<A: Allocator = +Global> {
    arena: ArenaLocal,
    allocator: A,
}

This is not valid Rust syntax… usually. But this struct definition is actually inside a macro call.

This crate uses a complex system of macros, which I didn’t spend the time to understand. It also doesn’t document the supported syntax, so I would only be guessing if I gave any interpretation for what it actually means.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading