-
Notifications
You must be signed in to change notification settings - Fork 33
Description
first:
pub(crate) static ref tess: Mutex<tesseract::Tesseract> = {
let datapath ="/tesspath";
let language ="/tesslang";
let mut _tess = tesseract::Tesseract::new(Some(datapath ), Some(language )).unwrap();
Mutex::new(_tess)
};
after:
let tess = crate::tess.lock().unwrap().set_image_from_mem(&[255]);
error:
201 | let tess = crate::tess.lock().unwrap().set_image_from_mem(&[255]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------
| | |
| | value moved due to this method call
| move occurs because value has type Tesseract, which does not implement the Copy trait
reason:
I looked at the set_image_from_mem method:
pub fn set_image_from_mem(
mut self,
img: &[u8],
) -> Result<Self, plumbing::leptonica_plumbing::PixReadMemError> {
let pix = plumbing::leptonica_plumbing::Pix::read_mem(img)?;
self.0.set_image_2(&pix);
Ok(self)
}
Can you change ownership to variable borrowing?
I want to use tesseracet instances globally, without having to use a new instance each time