From 79c1e531ff6a1986f9bb101a6fe4f763480b4b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=A4=8C?= <75060126+0xf90c@users.noreply.github.com> Date: Sat, 11 Jan 2025 23:35:09 +0500 Subject: [PATCH] update --- rustbook-uz/src/ch15-05-interior-mutability.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rustbook-uz/src/ch15-05-interior-mutability.md b/rustbook-uz/src/ch15-05-interior-mutability.md index 5110756..0b025a1 100644 --- a/rustbook-uz/src/ch15-05-interior-mutability.md +++ b/rustbook-uz/src/ch15-05-interior-mutability.md @@ -138,7 +138,10 @@ Then we create a new `LimitTracker` and give it a reference to the new we assert that the list of messages that the `MockMessenger` is keeping track of should now have one message in it. +Sinovda biz “LimitTracker”ga “qiymat”ni “maksimal” qiymatining 75 foizidan ko‘prog‘iga o‘rnatish buyurilganda nima sodir bo‘lishini sinab ko‘ramiz. Birinchidan, biz yangi "MockMessenger" ni yaratamiz, u xabarlarning bo'sh ro'yxati bilan boshlanadi. Keyin biz yangi `LimitTracker` yaratamiz va unga yangi `MockMessenger` va `max` qiymati 100 ga havola beramiz. 100ning 75 foizi. Keyin biz “MockMessenger” kuzatayotgan xabarlar roʻyxatida bitta xabar boʻlishi kerakligini taʼkidlaymiz. unda. + However, there’s one problem with this test, as shown here: +Biroq, bu testda ko'rsatilganidek, bitta muammo bor: ```console {{#include ../listings/ch15-smart-pointers/listing-15-21/output.txt}} @@ -150,6 +153,8 @@ suggestion from the error text to use `&mut self` instead, because then the signature of `send` wouldn’t match the signature in the `Messenger` trait definition (feel free to try and see what error message you get). +Biz “MockMessenger”ni xabarlarni kuzatib borish uchun o‘zgartira olmaymiz, chunki “yuborish” usuli “o‘z”ga o‘zgarmas havolani oladi. Shuningdek, xato matnidagi “&mut self” dan foydalanish taklifini qabul qila olmaymiz, chunki “yuborish” imzosi “Messenger” xususiyati taʼrifidagi imzoga toʻgʻri kelmasdi (xato boʻlganini koʻring. xabar olasiz). + This is a situation in which interior mutability can help! We’ll store the `sent_messages` within a `RefCell`, and then the `send` method will be able to modify `sent_messages` to store the messages we’ve seen. Listing 15-22