DS
Size: a a a
DS
DS
fn iterative(root: &RefCell<TreeNode>, l: i32, r: i32) -> i32 {
let mut stack = Vec::new();
stack.push(root.borrow());
let mut sum: i32 = 0;
while let Some(node) = stack.pop() {
if l <= node.val && node.val <= r {
sum += node.val;
}
if node.val < l {
match &node.left {
Some(left) => {
let tmp: &RefCell<TreeNode> = left.borrow();
stack.push(tmp.borrow());
}
None => {}
}
//node.borrow().left.map(|left| stack.push(left));
}
if node.val > r {
match &node.right {
Some(right) => {
let tmp: &RefCell<TreeNode> = right.borrow();
stack.push(tmp.borrow())
}
None => {}
}
//node.borrow().right.map(|right| stack.push(&right));
}
}
return sum;
}
Э
DS
DS
error[E0597]: `node` does not live long enough
--> src/main.rs:76:24
|
76 | match &node.right {
| ^^^^ borrowed value does not live long enough
...
85 | }
| - `node` dropped here while still borrowed
86 | return sum;
87 | }
| - borrow might be used here, when `stack` is dropped and runs the `Drop` code for type `std::vec::Vec`
|
= note: values in a scope are dropped in the opposite order they are defined
error: aborting due to previous error
DS
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
DS
DS
Э
Э
match &node.right {
перепиши на match node.right {
.DS
Э
DS
error[E0507]: cannot move out of dereference of `std::cell::Ref<'_, TreeNode>`
--> src/main.rs:66:23
|
66 | match node.left {
| ^^^^^^^^^ help: consider borrowing here: `&node.left`
67 | Some(left) => {
| ----
| |
| data moved here
| move occurs because `left` has type `std::rc::Rc<std::cell::RefCell<TreeNode>>`, which does not implement the `Copy` trait
error[E0597]: `left` does not live long enough
Э
let mut stack: Vec<&RefCell<_>> = Vec::new();
попробуй написать.DS
SS
diesel
и diesel_migrations
. Так вот, при компиляции все sql
миграции просто оказываются в бинаре.. H
diesel
и diesel_migrations
. Так вот, при компиляции все sql
миграции просто оказываются в бинаре.. [global.databases]
sqlite_logs = { url = "/path/to/database.sqlite" }
echo DATABASE_URL=postgres://username:password@localhost/diesel_demo > .env
H
∅ч
[global.databases]
sqlite_logs = { url = "/path/to/database.sqlite" }
echo DATABASE_URL=postgres://username:password@localhost/diesel_demo > .env
H