Call function in if satement

Hey guys,

I need to call some function that return bool value, inside a if statement.
So I have this code:

            #[weight = 10_000 + T::DbWeight::get().writes(2)]
    		pub fn unlock(origin) -> dispatch::DispatchResult {
    		    let user = ensure_signed(origin)?;
                ensure!(user == Self::authority(), Error::<T>::Forbidden);

Now I want to call it in if statement, but I don't know how, I try with this code, but returns me this:

if (Self::unlock) {
| ^^^^^^^^^^^^^^ expected bool, found fn item

If is unlock, then it should add amount on some accountId. Any help?

Self::unlock is a function, so you need to call it if you want its output like so:

if Self::unlock(origin) {...}

But given that unlock returns dispatch::DispatchResult you probably can't use that as a bool either, so you probably need to call is_ok() on it (or whatever it is you need.)

Thank for the reply, but I have another error:

if Self::unlock(origin).is_ok() {
^^^^^^ value used here after move

I think it's because I have this line:

let user = ensure_signed(origin)?;
^^^^^^ value used here after move

How can I resolve this?

Please post error messages in code blocks, not quote blocks. Also, please post full errors.