Hello,
My code is something like this (incomplete, of course, the whole code is very long):
However, on line 246, I'm getting the error "cannot return value referencing function parameter 'data'". Any ideas?
Thanks!
Hello,
My code is something like this (incomplete, of course, the whole code is very long):
Thanks!
Viewing that your code is in images (Markdown is supported here) I see that the return type in next_node
is Self
and not AdaptiveTransitionFunctionMapNode
, sometimes you can but like this time you ain't, the only thing afaik that you can do is change in line 246 Ref<'b, Self>
to Ref<'b, AdaptiveTransitionFunctionMapNode>
so the return types will match. Hope it helps ya!
This isn't making very much sense. Here's what I can gather:
Ref<'a, T>
doesn't have a method named get_cell_ref<'b>
, I presume that the second image with a function names get_cell_ref<'b>()
is from a trait implementation on Ref<'a, T>
.get_cell_ref<'b>
and I find self.is_link_get_vec()
which, looking at the second function in the second image, confuses me. is_link_get_vec()
is an impl
on the same Self
(Which we have thus far determined to be Ref<'a, T>
) and therefore the if let
statement makes no sense, unless there's some kind of magical type aliasing trickery.as_ref()
function on Rc
but I will assume that it returns a Ref<'b, Adaptive...Node>
(Which is supposed to be a Self
as we established that it was Ref<'b, T>
)next_node
(Which I have henceforth presumed to be the cause of the compiler error due to its red highlighting)Those methods are all custom methods I declared on AdaptiveTransitionFunctionMapNode, I'm using the auto deref to call them
data.get_cell_ref returns a Ref<'b, AdaptiveTransitionFunctionMapNode>. The issue is that the compiler says that I can't return a value that references a function parameter (data).
NOTE - I have tried changing the 3rd screnshot to be (data : &'b Ref<'b, Self>, however, still running into a few issues.
The issue is in another function:
Hmm, what happens if you swap out lines 190-194 with this:
let old = (1..input.len()).iter().fold(self.get_cell_ref(input[0]),
|acc, counter| {
Self::next_node(&acc, input[counter])
}
);