Dear All,
I am new on Rust, I want using Serde Destabilize struct that contain field uuid (byte) any help to archive that
`pub fn decode_serde<'de, T, R>(r: R) -> io::Result<T>
where
T: Deserialize<'de>,
R: io::Read,
{
Deserialize::deserialize(&mut Deserializer::new(r)).map_err(map_err_to_io)
}`
With Deserialize::deserialize
can modified to support uuid ?
Uuid
from the uuid
crate? Do you need some specific way of storing it in the table?
uuid
's serde
feature?
#[serde(with = "uuid::serde::compact")]
specified for that specific field, I think.
uuid::serde::compact
pub
so it's public despite being in a private module. If you mark it pub(crate)
instead, you'll see a privacy error.
extern crate
?
alloc
in no_std
environment without memory allocation, IIUC. There's a bit of discussion in rust-lang/rust#90507
smol::io::BufReader::new(smol::Unblock::new(reader))
Self
?
obj.methodA().methodB()
works if methodB
is defined on the return type of methodA
This program
struct Foo {
someString: String,
}
fn main() {
let x: Vec<Foo> = Vec::new();
x.sort_by_key(|foo| &foo.someString);
}
does not compile because
lifetime may not live long enough
returning this value requires that `'1` must outlive `'2`
I guess I should use x.sort_by()
instead in this case
does anybody know why cargo publish ignores the actual value of CARGO_PKG_VERSION
? i'm overriding the pkg version in build.rs for a project using:
println!("cargo:rustc-env=CARGO_PKG_VERSION=1.1.1");
but cargo publish seems to ignore that version and goes with the version in Cargo.toml. note in case of cargo build this is not the case.
yooo! Is there any way to extract the "index" (order of occurrence) of a struct field in a macro like this:
macro_rules! example {
(struct $name:ident {
$($field_name:ident: $field_type:ty,)*
}) => {
struct $name {
$($field_name: $field_type,)*
}
}
}
such that
example! {
struct Struct {
a: i32,
b: i32,
}
}
would have the index 0 associated to a
and 1 to b
etc. (for use in a particular impl)? =)