Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to return a reference for the values method of trait ObjectView #497

Open
videni opened this issue Apr 25, 2023 · 0 comments
Open

Comments

@videni
Copy link

videni commented Apr 25, 2023

Hi , I am trying to integrate this lib as a PHP extension using ext-php-rs.

Implementing liquid views for ZendObject and Zval.

pub struct ZendObjectView<'a>(pub &'a ZendObject);

impl<'a> liquid::ObjectView for ZendObjectView<'a> {

    //.....

    fn values<'k>(&'k self) -> Box<dyn Iterator<Item = &'k dyn ValueView> + 'k> {
        let values = self
            .0
            .get_properties()
            .unwrap()
            .iter()
            .map(|(_, _, v)| {
                // Will not work
                let z = ZvalView(v);

                return &z;
            });

        Box::new(values)
    }
   //....
}

type annotated for above values method

image

The ZvalView struct

image

Problems

the signature of the values method need a reference for ValueView, but in my case, I can never return a reference, any way to solve this problem please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant