Is it okay to copy-paste code from rustlang?

Sorry for getting your blood boiling :stuck_out_tongue: . I’m writing this crate for Rust bindings to the UEFI programming environment – think of it as the stdlib for UEFI. As a part of this crate I want to provide io::Read and io::Write traits similar to those found in stdlib and I want to implement some of the non-required methods in these traits (such as read_to_end()) . To this end, is it okay if I simply copy the equivalent code from stdlib and paste in my crate?

I know this looks questionable – and hence this question – but as I see it in a way my work more or less amounts to supporting a new platform in Rust (UEFI in this case) and it should be okay if this new platform uses the same code that other platforms do. Since this platform is no_std the only way I can implement parts of stdlib here is to copy-paste the code.

To be sure my own crate is licensed with an MIT license just like the rustlang repo. So in a way, by providing the text present in my own MIT license, I’m fulfilling the demands of rustlang’s MIT license since it’s almost the same text as required by the rustlang’s.

If this is not the right way, what options do I have?

1 Like

IANAL, but:

subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

As long as you keep the MIT licence file and add the copyright line from rust-lang (Copyright {year} The Rust Project Developers.), I think it’s fine. What constitutes a substantial portion is not clear, but better safe than sorry, and including the copyright notice is sort of like a nice attribution to the original authors.


Thanks @IsaacWoods.

As of now they’ve removed the copyright notice from rustlang’s license. As a result, my license’s text, which is also an MIT license itself, is now a complete superset of rustlang’s license text. Hence I’m thinking maybe my own license can serve the dual purpose of being both my license and a piece of text needed to fulfil the demands of rust’s license. In other words, in order to comply, I don’t need to keep any separate text other than what’s already present in my MIT license. Will this approach be valid? I know that probably no one here is a lawyer. Just seeking your opinion.

IANAL, but since Rust and most related code is dual-licensed under both MIT and Apache, don’t you need to do the same for your examples if they’re based on code snippets from those sources?

Hmm… I was assuming I had the choice of picking which license I want to honour, but you probably are right. Can anyone who put those license in in rustlang clarify?

Yes, that is what dual-licensing means, it is an OR between the license terms, not an AND.

@gurry instead of copying it yourself, you can use a crate that has already done that for you, such as core_io

1 Like

Thanks @mgeisler. So I’m kinda sorted then.

@jethrogb This is great. I may still have to have to copy stuff from std other than io, but this will be a great help. Thanks :slight_smile: