Skip to content

Cache member functions? #86

@matthiasbeyer

Description

@matthiasbeyer

Hi.

I don't know why this isn't possible yet, and while searching the issues I did not find something that answered my questions: Why is there no caching for member functions?

Consider:

pub struct Foo(i32, i32);

impl Foo {
    #[cached]
    pub fn get_first(&self) -> i32 { /* ... */ }
    #[cached]
    pub fn get_snd(&self) -> i32 { /* ... */ }
}

That's actually not that hard to cache, is it? Maybe I'm missing some important pieces here, I don't know...


That being said, one could easily craft a type which just calls (cached) free private functions, like so:

pub struct Foo(i32, i32);

impl Foo {
    pub fn get_first(&self) -> i32 { foo_get_first(self) }
    pub fn get_snd(&self) -> i32 { foo_get_snd(self) }
}

#[cached]
fn foo_get_first(f: &Foo) -> i32 { /* ... */ }
#[cached]
fn foo_get_snd(f: &Foo) -> i32 { /* ... */ }

right? That'd yield the same, AFAICS?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions