Skip to content

Conversation

TroyKomodo
Copy link

from_fn allows generics and extends the ability of the default from attribute, it also allows for foreign types to be converted, if they dont implement the correct traits.

pub struct Example {
    #[from_row(from_fn = "json")]
    json: HashMap<String, bool>,
}

fn json<T>(wrapper: Json<T>) -> T {
    wrapper.0
}

`from_fn` allows generics and extends the ability of the default `from`
attribute, it also allows for foreign types to be converted, if they
dont implement the correct traits.

```rs
pub struct Example {
    #[from_row(from_fn = "json")]
    json: HashMap<String, bool>,
}

fn json<T>(wrapper: Json<T>) -> T {
    wrapper.0
}
```
@TroyKomodo
Copy link
Author

@remkop22 bump

@guspower
Copy link

guspower commented Mar 1, 2025

@remkop22 I'm using this feature by having this branch locally and configuring Cargo.toml postgres-from-row = { path = "../postgres-from-row" }

It would be great to get this feature into main and a new release out; if I can help at all please let me know.

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

Successfully merging this pull request may close these issues.

2 participants