replace Cell with RefCell

This commit is contained in:
yggverse 2024-12-15 18:05:39 +02:00
parent f0e36e711d
commit 24160d39eb
2 changed files with 5 additions and 4 deletions

View File

@ -124,7 +124,7 @@ fn find(
}
fn update(entry: &Entry, navigation: &Rc<Navigation>) {
if navigation.matches.take().is_empty() {
if navigation.matches.borrow().is_empty() {
entry.add_css_class("error");
navigation.back.set_sensitive(false);
navigation.forward.set_sensitive(false);

View File

@ -2,7 +2,7 @@ mod back;
mod forward;
use gtk::{prelude::BoxExt, Box, Button, Orientation, TextIter};
use std::{cell::Cell, rc::Rc};
use std::{cell::RefCell, rc::Rc};
const MARGIN: i32 = 6;
@ -10,7 +10,7 @@ pub struct Navigation {
pub back: Button,
pub forward: Button,
pub g_box: Box,
pub matches: Rc<Cell<Vec<(TextIter, TextIter)>>>,
pub matches: Rc<RefCell<Vec<(TextIter, TextIter)>>>,
}
impl Navigation {
@ -18,7 +18,8 @@ impl Navigation {
/// Create new `Self`
pub fn new() -> Self {
let matches = Rc::new(Cell::new(Vec::new()));
// Init shared matches holder
let matches = Rc::new(RefCell::new(Vec::new()));
// Init components
let back = back::new();