Rust – Creating a Library
Rust is a multi-paradigm programming language like C++ syntax that was designed for performance and safety, especially for safe concurrency. Also, it is a compiled system programming language. In this article, we will see how to create libraries in Rust.
Creating a Rust Library:
Step 1: We start by creating a .rs file called rary.rs. This file contains the contents of our library.
Step 2: Now we will create this library using the following command.
$ rustc --crate-type=lib rary.rs
Step 3: The above command will generate file “library.rlib” . All libraries get prefixed with “lib” and by default, they are named after their create file. So “library.rlib” –> lib + rary + .rlib
Step 4: The following command can override the default name.
$ rustc --crate-type=lib rary.rs --create-name "<Name of your choice>"
So, by using the above steps you can create our own Rust library.
Please Login to comment...