Introduction to the relationships, packages, and modules of Rust function functions

Source: Internet
Author: User
Relationship of Rust function functions, Introduction to packages and modules I. Relationship between function functions

As you can see earlier, multiple function functions can be defined in a file, and these function functions may be used by each other. The entrance to the program is main ().

In a file, the definition and use of each function function are not constrained by the order defined by the function function. That is, there is no need to have a declaration statement, like in C, before a function is used and a function is not defined, and as in Java, as long as a function function is declared within a file, the order in which the function functions appear in the file can be ignored.

II. Package Management of documents

When there are more and more function functions in a file, reading and modifying are a problem. Therefore, functional separation is required, and function functions are saved in separate files according to the operation or function.

In addition, from the perspective of software engineering to consider the reuse and encapsulation of software, some functions need to be set to external access to public, and some are designed for internal use only private.

The Rust project's package management uses the term crate, which is equivalent to the packages in Java.
Cargo is a built-in package management tool for rust.

A crate can be a rust program that can be run, or it can be a library repository for functional functions (like Android's project to differentiate between running apps and Lib).

In addition to crate, Rust also provides a mechanism for module modules. Multiple module modules can be included in each crate, one of which is assumed to be (root module) root modules. The root module and other modules form a tree structure, just like the relationship between the root element in an XML file and the other child elements, or the relationships of multiple subfolders contained in a folder.

Before you do the module and combat operations, introduce Rust's project management tools: Cargo, which has been used in previous articles, like the Maven tools in Java, for project creation, compilation, running, packaging, deployment, and dependencies between packages, dependent on automatic download and update of packages.

Introduction to the relationships, packages, and modules of Rust function functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.