diff --git a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-05/Cargo.lock b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-05/Cargo.lock index df19c247..9ecfaf0f 100644 --- a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-05/Cargo.lock +++ b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-05/Cargo.lock @@ -1,6 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] -name = "art" +name = "rassom" version = "0.1.0" - diff --git a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/Cargo.toml b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/Cargo.toml index 66ef4b53..c2e2c607 100644 --- a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/Cargo.toml +++ b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "art" +name = "rassom" version = "0.1.0" edition = "2021" diff --git a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/lib.rs b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/lib.rs index daabd006..5ff64b2f 100644 --- a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/lib.rs +++ b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/lib.rs @@ -1,33 +1,33 @@ -//! # Art +//! # Rassom //! -//! A library for modeling artistic concepts. +//! Badiiy tushunchalarni modellashtirish uchun kutubxona. -pub use self::kinds::PrimaryColor; -pub use self::kinds::SecondaryColor; -pub use self::utils::mix; +pub use self::turlar::AsosiyRang; +pub use self::turlar::IkkilamchiRang; +pub use self::yordamchi::yordamchi; -pub mod kinds { - /// The primary colors according to the RYB color model. - pub enum PrimaryColor { - Red, - Yellow, - Blue, +pub mod turlar { + /// RYB rang modeliga muvofiq asosiy ranglar. + pub enum AsosiyRang { + Qizil, + Sariq, + Kok, } - /// The secondary colors according to the RYB color model. - pub enum SecondaryColor { - Orange, - Green, - Purple, + /// RYB rang modeliga muvofiq ikkinchi darajali ranglar. + pub enum IkkilamchiRang { + Qovoqrang, + Yashil, + Siyohrang, } } -pub mod utils { - use crate::kinds::*; +pub mod yordamchi { + use crate::turlar::*; - /// Combines two primary colors in equal amounts to create - /// a secondary color. - pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor { - SecondaryColor::Orange + /// Ikkilamchi rang yaratish uchun ikkita asosiy rangni teng + /// miqdorda birlashtiradi. + pub fn yordamchi(c1: AsosiyRang, c2: AsosiyRang) -> IkkilamchiRang { + IkkilamchiRang::Qovoqrang } } diff --git a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/main.rs b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/main.rs index 51f3b761..c87ed060 100644 --- a/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/main.rs +++ b/rustbook-uz/listings/ch14-more-about-cargo/listing-14-06/src/main.rs @@ -1,13 +1,13 @@ // ANCHOR: here -use art::mix; -use art::PrimaryColor; +use rassom::aralashtirish; +use rassom::AsosiyRang; fn main() { // --snip-- // ANCHOR_END: here - let red = PrimaryColor::Red; - let yellow = PrimaryColor::Yellow; - mix(red, yellow); + let qizil = AsosiyRang::qizil; + let sariq = AsosiyRang::Sariq; + mix(qizil, sariq); // ANCHOR: here } // ANCHOR_END: here diff --git a/rustbook-uz/src/ch14-02-publishing-to-crates-io.md b/rustbook-uz/src/ch14-02-publishing-to-crates-io.md index 0e8a08c1..e62ee9c8 100644 --- a/rustbook-uz/src/ch14-02-publishing-to-crates-io.md +++ b/rustbook-uz/src/ch14-02-publishing-to-crates-io.md @@ -135,18 +135,13 @@ Ichki organizationni public API’dan olib tashlash uchun biz 14-5 ro‘yxatda k Ro'yxat 14-5: Elementlarni qayta eksport qilish uchun `pub use` statementlarini qo'shish -The API documentation that `cargo doc` generates for this crate will now list -and link re-exports on the front page, as shown in Figure 14-4, making the -`PrimaryColor` and `SecondaryColor` types and the `mix` function easier to find. +Ushbu crate uchun `cargo doc` yaratadigan API hujjatlari Endi 14-4-rasmda ko'rsatilganidek, re-exportlarni birinchi sahifada listga oling va bog'lang, bu `AsosiyRang` va `IkkilamchiRang` turlarini va `aralashtirish` funksiyasini topishni osonlashtiradi. -Rendered documentation for the `art` crate with the re-exports on the front page +Rendered documentation for the `art` crate with the re-exports on the front page -Figure 14-4: The front page of the documentation for `art` -that lists the re-exports +14-4-rasm: re-exportlar ro'yxati keltirilgan `rassom` hujjatlarining birinchi sahifasi -The `art` crate users can still see and use the internal structure from Listing -14-3 as demonstrated in Listing 14-4, or they can use the more convenient -structure in Listing 14-5, as shown in Listing 14-6: +`rassom` crate foydalanuvchilari hali ham 14-4 roʻyxatda koʻrsatilganidek, 14-3 roʻyxatdagi ichki(internal) structureni koʻrishlari va foydalanishlari mumkin yoki ular 14-6 roʻyxatda koʻrsatilganidek, 14-5 roʻyxatdagi qulayroq structuredan foydalanishlari mumkin: Fayl nomi: src/main.rs @@ -154,21 +149,11 @@ structure in Listing 14-5, as shown in Listing 14-6: {{#rustdoc_include ../listings/ch14-more-about-cargo/listing-14-06/src/main.rs:here}} ``` -Listing 14-6: A program using the re-exported items from -the `art` crate - -In cases where there are many nested modules, re-exporting the types at the top -level with `pub use` can make a significant difference in the experience of -people who use the crate. Another common use of `pub use` is to re-export -definitions of a dependency in the current crate to make that crate's -definitions part of your crate’s public API. - -Creating a useful public API structure is more of an art than a science, and -you can iterate to find the API that works best for your users. Choosing `pub -use` gives you flexibility in how you structure your crate internally and -decouples that internal structure from what you present to your users. Look at -some of the code of crates you’ve installed to see if their internal structure -differs from their public API. +Ro'yxat 14-6: `rassom` cratesidan re-export(qayta eksport) qilingan itemlarni ishlatadigan dastur + +Ko'plab ichki modullar mavjud bo'lsa, `pub use` bilan top leveldagi turlarni qayta eksport(re-export) qilish cratedan foydalanadigan foydalanuvchilar tajribasida sezilarli o'zgarishlarga olib kelishi mumkin. `pub use` ning yana bir keng tarqalgan qoʻllanilishi bu crate deifinationlarini cratengizning public API qismiga aylantirish uchun joriy cratedagi dependency definitionlarini qayta eksport qilishdir. + +Foydali public API stucturesini yaratish fandan ko'ra ko'proq san'atdir va siz foydalanuvchilaringiz uchun eng mos keladigan APIni topish uchun takrorlashingiz mumkin. `pub use` ni tanlash sizga cratengizni ichki stuctureda moslashuvchanlikni beradi va bu ichki stuctureni foydalanuvchilarga taqdim etgan narsadan ajratadi. O'rnatgan ba'zi cratelar kodlarini ko'rib chiqing, ularning ichki tuzilishi(internal structure) public APIdan farq qiladimi yoki yo'qmi. ### Setting Up a Crates.io Account diff --git a/rustbook-uz/src/img/trlpuz14.png b/rustbook-uz/src/img/trlpuz14.png new file mode 100644 index 00000000..a1621690 Binary files /dev/null and b/rustbook-uz/src/img/trlpuz14.png differ