Skip to content

Commit

Permalink
use unqualified path for core
Browse files Browse the repository at this point in the history
  • Loading branch information
knickish committed Apr 18, 2024
1 parent ef959a2 commit a2e35b5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
16 changes: 8 additions & 8 deletions derive/src/serde_bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub fn derive_ser_bin_proxy(proxy_type: &str, type_: &str) -> TokenStream {
pub fn derive_de_bin_proxy(proxy_type: &str, type_: &str) -> TokenStream {
format!(
"impl DeBin for {} {{
fn de_bin(o:&mut usize, d:&[u8]) -> core::result::Result<Self, nanoserde::DeBinErr> {{
fn de_bin(o:&mut usize, d:&[u8]) -> ::core::result::Result<Self, nanoserde::DeBinErr> {{
let proxy: {} = DeBin::de_bin(o, d)?;
core::result::Result::Ok(Into::into(&proxy))
::core::result::Result::Ok(Into::into(&proxy))
}}
}}",
type_, proxy_type
Expand Down Expand Up @@ -126,8 +126,8 @@ pub fn derive_de_bin_struct(struct_: &Struct) -> TokenStream {

format!(
"impl{} DeBin for {}{} {{
fn de_bin(o:&mut usize, d:&[u8]) -> core::result::Result<Self, nanoserde::DeBinErr> {{
core::result::Result::Ok(Self {{
fn de_bin(o:&mut usize, d:&[u8]) -> ::core::result::Result<Self, nanoserde::DeBinErr> {{
::core::result::Result::Ok(Self {{
{}
}})
}}
Expand Down Expand Up @@ -161,8 +161,8 @@ pub fn derive_de_bin_struct_unnamed(struct_: &Struct) -> TokenStream {

format!(
"impl{} DeBin for {}{} {{
fn de_bin(o:&mut usize, d:&[u8]) -> core::result::Result<Self, nanoserde::DeBinErr> {{
core::result::Result::Ok(Self {{
fn de_bin(o:&mut usize, d:&[u8]) -> ::core::result::Result<Self, nanoserde::DeBinErr> {{
::core::result::Result::Ok(Self {{
{}
}})
}}
Expand Down Expand Up @@ -321,11 +321,11 @@ pub fn derive_de_bin_enum(enum_: &Enum) -> TokenStream {

format!(
"impl{} DeBin for {}{} {{
fn de_bin(o:&mut usize, d:&[u8]) -> core::result::Result<Self, nanoserde::DeBinErr> {{
fn de_bin(o:&mut usize, d:&[u8]) -> ::core::result::Result<Self, nanoserde::DeBinErr> {{
let id: u16 = DeBin::de_bin(o,d)?;
Ok(match id {{
{}
_ => return core::result::Result::Err(nanoserde::DeBinErr{{o:*o, l:0, s:d.len()}})
_ => return ::core::result::Result::Err(nanoserde::DeBinErr{{o:*o, l:0, s:d.len()}})
}})
}}
}}", generic_w_bounds,enum_.name,generic_no_bounds, r)
Expand Down
26 changes: 13 additions & 13 deletions derive/src/serde_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub fn derive_de_json_named(name: &str, defaults: bool, fields: &[Field]) -> Tok
// TODO: maybe introduce "exhaustive" attribute?
// l!(
// r,
// "_ => return core::result::Result::Err(s.err_exp(&s.strbuf))"
// "_ => return ::core::result::Result::Err(s.err_exp(&s.strbuf))"
// );
l!(r, "_ => {s.next_colon(i)?; s.whole_field(i)?; }");
l!(r, "}");
Expand All @@ -223,9 +223,9 @@ pub fn derive_de_json_proxy(proxy_type: &str, type_: &str) -> TokenStream {
format!(
"impl DeJson for {} {{
#[allow(clippy::ignored_unit_patterns)]
fn de_json(_s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> core::result::Result<Self, nanoserde::DeJsonErr> {{
fn de_json(_s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> ::core::result::Result<Self, nanoserde::DeJsonErr> {{
let proxy: {} = DeJson::deserialize_json(i)?;
core::result::Result::Ok(Into::into(&proxy))
::core::result::Result::Ok(Into::into(&proxy))
}}
}}",
type_, proxy_type
Expand All @@ -249,9 +249,9 @@ pub fn derive_de_json_struct(struct_: &Struct) -> TokenStream {
format!(
"impl{} DeJson for {}{} {{
#[allow(clippy::ignored_unit_patterns)]
fn de_json(s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> core::result::Result<Self,
fn de_json(s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> ::core::result::Result<Self,
nanoserde::DeJsonErr> {{
core::result::Result::Ok({{ {} }})
::core::result::Result::Ok({{ {} }})
}}
}}", generic_w_bounds, struct_.name.as_ref().expect("Cannot implement for anonymous struct"), generic_no_bounds, body)
.parse().unwrap()
Expand Down Expand Up @@ -462,7 +462,7 @@ pub fn derive_de_json_enum(enum_: &Enum) -> TokenStream {
let mut r = format!(
"impl{} DeJson for {}{} {{
#[allow(clippy::ignored_unit_patterns)]
fn de_json(s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> core::result::Result<Self, nanoserde::DeJsonErr> {{
fn de_json(s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> ::core::result::Result<Self, nanoserde::DeJsonErr> {{
match s.tok {{",
generic_w_bounds, generic_no_bounds, enum_.name,
);
Expand All @@ -474,9 +474,9 @@ pub fn derive_de_json_enum(enum_: &Enum) -> TokenStream {
s.curly_open(i)?;
let _ = s.string(i)?;
s.colon(i)?;
let r = core::result::Result::Ok(match s.strbuf.as_ref() {{
let r = ::core::result::Result::Ok(match s.strbuf.as_ref() {{
{}
_ => return core::result::Result::Err(s.err_enum(&s.strbuf))
_ => return ::core::result::Result::Err(s.err_enum(&s.strbuf))
}});
s.curly_close(i)?;
r
Expand All @@ -490,9 +490,9 @@ pub fn derive_de_json_enum(enum_: &Enum) -> TokenStream {
"
nanoserde::DeJsonTok::Str => {{
let _ = s.string(i)?;
core::result::Result::Ok(match s.strbuf.as_ref() {{
::core::result::Result::Ok(match s.strbuf.as_ref() {{
{}
_ => return core::result::Result::Err(s.err_enum(&s.strbuf))
_ => return ::core::result::Result::Err(s.err_enum(&s.strbuf))
}})
}},",
r_units,
Expand All @@ -501,7 +501,7 @@ pub fn derive_de_json_enum(enum_: &Enum) -> TokenStream {

r.push_str(
r#"
_ => core::result::Result::Err(s.err_token("String or {")),
_ => ::core::result::Result::Err(s.err_token("String or {")),
}
}
}
Expand Down Expand Up @@ -596,9 +596,9 @@ pub fn derive_de_json_struct_unnamed(struct_: &Struct) -> TokenStream {
format! ("
impl{} DeJson for {}{} {{
#[allow(clippy::ignored_unit_patterns)]
fn de_json(s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> core::result::Result<Self,nanoserde::DeJsonErr> {{
fn de_json(s: &mut nanoserde::DeJsonState, i: &mut core::str::Chars) -> ::core::result::Result<Self,nanoserde::DeJsonErr> {{
{}
core::result::Result::Ok(r)
::core::result::Result::Ok(r)
}}
}}",generic_w_bounds, struct_.name.as_ref().expect("Cannot implement for anonymous struct"), generic_no_bounds, body
).parse().unwrap()
Expand Down
20 changes: 10 additions & 10 deletions derive/src/serde_ron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub fn derive_ser_ron_proxy(proxy_type: &str, type_: &str) -> TokenStream {
pub fn derive_de_ron_proxy(proxy_type: &str, type_: &str) -> TokenStream {
format!(
"impl DeRon for {} {{
fn de_ron(_s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> core::result::Result<Self, nanoserde::DeRonErr> {{
fn de_ron(_s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> ::core::result::Result<Self, nanoserde::DeRonErr> {{
let proxy: {} = DeRon::deserialize_ron(i)?;
core::result::Result::Ok(Into::into(&proxy))
::core::result::Result::Ok(Into::into(&proxy))
}}
}}",
type_, proxy_type
Expand Down Expand Up @@ -221,7 +221,7 @@ pub fn derive_de_ron_named(
format!(
"match s.identbuf.as_ref() {{
{}
_ => return core::result::Result::Err(s.err_exp(&s.identbuf))
_ => return ::core::result::Result::Err(s.err_exp(&s.identbuf))
}}",
inner
)
Expand Down Expand Up @@ -264,8 +264,8 @@ pub fn derive_de_ron_struct(struct_: &Struct) -> TokenStream {

format!(
"impl DeRon for {} {{
fn de_ron(s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> core::result::Result<Self,nanoserde::DeRonErr> {{
core::result::Result::Ok({})
fn de_ron(s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> ::core::result::Result<Self,nanoserde::DeRonErr> {{
::core::result::Result::Ok({})
}}
}}", struct_.name.as_ref().expect("Cannot implement for anonymous struct"), body)
.parse()
Expand All @@ -288,11 +288,11 @@ pub fn derive_de_ron_struct_unnamed(struct_: &Struct) -> TokenStream {

format! ("
impl DeRon for {} {{
fn de_ron(s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> core::result::Result<Self,nanoserde::DeRonErr> {{
fn de_ron(s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> ::core::result::Result<Self,nanoserde::DeRonErr> {{
s.paren_open(i)?;
let r = Self({});
s.paren_close(i)?;
core::result::Result::Ok(r)
::core::result::Result::Ok(r)
}}
}}",struct_.name.as_ref().expect("Cannot implement for anonymous struct"), body
).parse().unwrap()
Expand Down Expand Up @@ -465,12 +465,12 @@ pub fn derive_de_ron_enum(enum_: &Enum) -> TokenStream {

format! ("
impl DeRon for {} {{
fn de_ron(s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> core::result::Result<Self,nanoserde::DeRonErr> {{
fn de_ron(s: &mut nanoserde::DeRonState, i: &mut core::str::Chars) -> ::core::result::Result<Self,nanoserde::DeRonErr> {{
// we are expecting an identifier
s.ident(i)?;
core::result::Result::Ok(match s.identbuf.as_ref() {{
::core::result::Result::Ok(match s.identbuf.as_ref() {{
{}
_ => return core::result::Result::Err(s.err_enum(&s.identbuf))
_ => return ::core::result::Result::Err(s.err_enum(&s.identbuf))
}})
}}
}}", enum_.name, body).parse().unwrap()
Expand Down

0 comments on commit a2e35b5

Please sign in to comment.