Skip to content

Commit

Permalink
Merge pull request #217 from mlabs-haskell/szg251/lbr-prelude-derive
Browse files Browse the repository at this point in the history
lbr-prelude-derive: fully qualify Result to solve conflicts with user defined Result type in target module
  • Loading branch information
szg251 authored May 23, 2024
2 parents 22728a2 + 3f60380 commit f5acbc0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions runtimes/rust/lbr-prelude-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn impl_struct(
let keys = named.iter().map(|field| &field.ident);

let from_json_impl = quote! {
fn from_json(value: &serde_json::Value) -> Result<Self, lbr_prelude::error::Error> {
fn from_json(value: &serde_json::Value) -> std::result::Result<Self, lbr_prelude::error::Error> {
match value {
serde_json::Value::Object(dict) => {
#(#dict_get)*
Expand Down Expand Up @@ -135,7 +135,7 @@ fn impl_tuple(
};

let from_json_impl = quote! {
fn from_json(value: &serde_json::Value) -> Result<Self, lbr_prelude::error::Error> {
fn from_json(value: &serde_json::Value) -> std::result::Result<Self, lbr_prelude::error::Error> {
Vec::from_json(value).and_then(|vec: Vec<serde_json::Value>| {
if vec.len() == #arity {
Ok(Self(
Expand Down Expand Up @@ -166,7 +166,7 @@ fn impl_newtype() -> (proc_macro2::TokenStream, proc_macro2::TokenStream) {
};

let from_json_impl = quote! {
fn from_json(value: &serde_json::Value) -> Result<Self, lbr_prelude::error::Error> {
fn from_json(value: &serde_json::Value) -> std::result::Result<Self, lbr_prelude::error::Error> {
Ok(Self(lbr_prelude::json::Json::from_json(value)?))
}
};
Expand Down Expand Up @@ -269,7 +269,7 @@ fn impl_enum(
});

let from_json_impl = quote! {
fn from_json(value: &serde_json::Value) -> Result<Self, lbr_prelude::error::Error> {
fn from_json(value: &serde_json::Value) -> std::result::Result<Self, lbr_prelude::error::Error> {
lbr_prelude::json::case_json_constructor(#ident_str, vec![
#(#from_json_match_arms),*
],
Expand Down

0 comments on commit f5acbc0

Please sign in to comment.