Skip to content

Commit

Permalink
big changes updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ismoilovdevml committed Nov 25, 2023
1 parent 435ff00 commit 4b9ebff
Show file tree
Hide file tree
Showing 34 changed files with 74 additions and 76 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]

members = [
"qoshuvchi",
"bitta_qoshish",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "qoshish"
version = "0.1.0"
edition = "2021"

[dependencies]

bitta_qoshish = { path = "../bitta_qoshish" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use bitta_qoshish;

fn main() {
let raqam = 10;
println!("Salom, Rust! {raqam} plyus bir {} ga teng!!", bitta_qoshish::bitta_qoshish(raqam));
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Orzularing o'zingnikimi?");
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]

members = [
"qoshuvchi",
"bitta_qoshish",
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "add_one"
name = "bitta_qoshish"
version = "0.1.0"
edition = "2021"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn bitta_qoshish(x: i32) -> i32 {
x + 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "qoshuvchi"
version = "0.1.0"
edition = "2021"

[dependencies]
bitta_qoshish = { path = "../bitta_qoshish" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Orzularing o'zingnikimi?");
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]

members = [
"qoshuvchi",
"bitta_qoshish",
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "add_one"
name = "bitta_qoshish"
version = "0.1.0"
edition = "2021"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use rand;

pub fn bitta_qoshish(x: i32) -> i32 {
x + 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "qoshuvchi"
version = "0.1.0"
edition = "2021"

[dependencies]

bitta_qoshish = { path = "../bitta_qoshish" }
22 changes: 10 additions & 12 deletions rustbook-uz/src/ch14-03-cargo-workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Buning o'rniga, u binary(ikkilik) crate yordamida paketga yo'lni ko'rsatib, work
<span class="filename">Fayl nomi: Cargo.toml</span>

```toml
{{#include ../listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/add/Cargo.toml}}
{{#include ../listings/ch14-more-about-cargo/no-listing-01-workspace-with-adder-crate/qoshish/Cargo.toml}}
```

Keyin, *qoshuvchi* jilida `cargo new` ni ishga tushirish orqali `qoshuvchi` binary cratesini yaratamiz:
Expand Down Expand Up @@ -56,7 +56,7 @@ Keyinchalik, workspaceda boshqa a'zolar(member) paketini yaratamiz va uni `bitta
<span class="filename">Fayl nomi: Cargo.toml</span>

```toml
{{#include ../listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/Cargo.toml}}
{{#include ../listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/qoshish/Cargo.toml}}
```

Keyin `bitta_qoshish` nomli yangi kutubxonalibrary cratesini yarating:
Expand Down Expand Up @@ -94,15 +94,15 @@ Sizning *qoshish* jildingizda endi quyidagi jild va fayllar bo‘lishi kerak:
<span class="filename">Fayl nomi: bitta_qoshish/src/lib.rs</span>

```rust,noplayground
{{#rustdoc_include ../listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/add_one/src/lib.rs}}
{{#rustdoc_include ../listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/qoshish/bitta_qoshish/src/lib.rs}}
```

Endi biz kutubxonamizga ega bo'lgan `bitta_qoshish` paketiga bog'liq bo'lgan `qoshuvchi` paketiga ega bo'lishimiz mumkin. Birinchidan, biz *qoshuvchi/Cargo.toml* ga `bitta_qoshish` yo'liga bog'liqlikni qo'shishimiz kerak.

<span class="filename">Fayl nomi: qoshuvchi/Cargo.toml</span>

```toml
{{#include ../listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/adder/Cargo.toml:6:7}}
{{#include ../listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/qoshish/qoshuvchi/Cargo.toml:6:7}}
```

Cargo workspacedagi cratelar bir-biriga bog'liq bo'ladi deb o'ylamaydi, shuning uchun biz qaramlik munosabatlari(relationship) haqida aniq bo'lishimiz kerak.
Expand All @@ -112,7 +112,7 @@ Keyin, keling, `qoshuvchi` cratedagi `bitta_qoshish` funksiyasidan (`bitta_qoshi
<span class="filename">Fayl nomi: qoshuvchi/src/main.rs</span>

```rust,ignore
{{#rustdoc_include ../listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs}}
{{#rustdoc_include ../listings/ch14-more-about-cargo/listing-14-07/qoshish/qoshuvchi/src/main.rs}}
```

<span class="caption">Roʻyxat 14-7: `bitta_qoshish` kutubxonasi cratesidan `qoshish` cratesidan foydalanish</span>
Expand All @@ -127,14 +127,12 @@ copy output below; the output updating script doesn't handle subdirectories in p

```console
$ cargo build
Compiling add_one v0.1.0 (file:///projects/qoshish/bitta_qoshish)
Compiling bitta_qoshish v0.1.0 (file:///projects/qoshish/bitta_qoshish)
Compiling qoshuvchi v0.1.0 (file:///projects/qoshish/qoshuvchi)
Finished dev [unoptimized + debuginfo] target(s) in 0.68s
```

To run the binary crate from the *add* directory, we can specify which
package in the workspace we want to run by using the `-p` argument and the
package name with `cargo run`:
Binary crateni *qoshish* jildidan ishga tushirish uchun biz `-p` argumenti va `cargo run` bilan paket nomidan foydalanib workspaceda qaysi paketni ishga tushirishni belgilashimiz mumkin:

<!-- manual-regeneration
cd listings/ch14-more-about-cargo/listing-14-07/add
Expand All @@ -143,13 +141,13 @@ copy output below; the output updating script doesn't handle subdirectories in p
-->

```console
$ cargo run -p adder
$ cargo run -p qoshuvchi
Finished dev [unoptimized + debuginfo] target(s) in 0.0s
Running `target/debug/adder`
Running `target/debug/qoshuvchi`
Hello, world! 10 plus one is 11!
```

This runs the code in *adder/src/main.rs*, which depends on the `add_one` crate.
Bu kodni *qoshuvchi/src/main.rs* da ishga tushiradi, bu `bitta_qoshish` cratesiga bog'liq.

#### Depending on an External Package in a Workspace

Expand Down

0 comments on commit 4b9ebff

Please sign in to comment.