Replies: 1 comment
-
Taking ownership of the the object before passing it to the instantiation function, and then borrowing it from within the object's functions - instead of having the borrowed value be passed to the function, proved to be the correct answer. At least, that's what I think I did. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to bind several Java functions from a library into Rust code. I have this struct:
and this method:
pub fn name( &'mc mut self, ) -> Result<&'mc mut crate::bungee::api::chat::BaseComponent<'mc>, Box<dyn std::error::Error>> { let res = self.0.call_method( &self.1, - ^^^^^^^ the trait `AsRef<JObject<'_>>` is not implemented for `JValueGen<JObject<'mc>>` "getName", "(V)Lnet/md_5/bungee/api/chat/BaseComponent", &[], )?; let mut ret = { self.3.push(res); let len = self.3.len(); crate::bungee::api::chat::BaseComponent( self.0, &mut self.3[len - 1], ( Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), (), ), Vec::new(), ) }; let len = self.2 .0.len(); &self.2 .0.push(&mut ret); Ok(self.2 .0[len - 1]) }
JValueGen<JObject<'mc>> is owned by
self
, and I have found that I can't create a JObject<'mc> and pass it into the instantiation function of a similar object without getting lifetime errors.Beta Was this translation helpful? Give feedback.
All reactions