text: These are chat archives for rust-lang/rust
  error[E0428]: the name `_` is defined multiple times note: `_` must be defined only once in the macro namespace of this module
  _, that shouldn't be a problem since
  _is a placeholder
  _in any case
  @omni-viral I have a branch with the issues and everything is open. this is the memory free that if uncommented causes segfault this is the function that should convert from
  ImageData to
  VipsImage, but the generated
  VipsImage is then segfaulting if you try to convert it back to
  ImageData using the previous function.
  fn main() { let foo = 2; let bar = Box::new(foo); // let baz = &bar; // baz is &Box<i32> // f(&*baz); f(&bar); } fn f(a: &i32) { println!("{}", a); }
  What's different between & and ref ?
  yew = { git = '' }cause
  cargo vendorto generate a sync error "the source path is not an existing regular file"? I need to access the dependency either using git or path because I am developing off of a release that hasn't been sync'd to crates yet
  git =, but
  path =.
  let some:i8 = 0Is the only way to zero initialize a variable?
  let some:i8( )or let
  some:i8{ }
  fn main() { let a: i8 = Default::default(); println!("{}", a); }
  fn somefn () - > i8{ }here, I don't wanna type
  0i8or call
  Default::default();I simply wanna return like
  fn somefn () - > i8{ () }
  ()has a type, all I thought was it would call the constructor like function for any type
  T,since primitive types doesn't have constructor I thought it would be zero initialized.
  ()has type
  ()which is empty tuple called unit btw, same as haskell does it
  g_object_unrefis wrong function to free memory I suppose. It takes refcounted object like
  VipsImagenot just allocated memory
  freefrom
  libc
  unsafe { <safety note from `foo`>: <explanation why it is valid> <safety note from `bar`>: <explanation why it is valid> <safety note from `baz`>: <explanation why it is valid> foo(bar(baz())); }
  libc::free(memory as *mut libc::c_void);seems to do the job
  let vector: Vec<u8> = unsafe { /// # Safety /// memory needs to be freed manually let mut result_size: usize = 0; let memory: *mut u8 = vips::vips_image_write_to_memory( self.img, &mut result_size as *mut usize, ) as *mut u8; let slice = slice::from_raw_parts_mut(memory, result_size); let vec = slice.to_vec(); // manually free the memory libc::free(memory as *mut libc::c_void); vec };
  fn somefn()->String {}and I want to return its caller an empty string ( meaning
  "") , I could just write it as(if supported )
  fn somefn()->String { () }which I basically thought would default construct the type
  Stringwith an empty literal , so am kinda looking for a way where I could use either
  ()or
  {}or any
  xyzthat can default construct an object in a much simpler way rather than explicitly mentioning empty values
  fn somefn()->String { String::xxx() }. that's where the whole thing started.
  Default::default()is for. I think in this case it's better to be explicit about what you're returning, whether it's
  0i8or
  "".to_owned().
  Defaultwas implemented for numbers and strings because it didn't have to be zero or empty.
  @Fantasized OK, just write your own procedural macro:
  #![some_magic] ... fn somefn() -> String { @_@ } // ==> fn somefn() -> String { <String as Default>::default() } fn another_somefn() -> i32 { @_@ } // ==> fn another_somefn() -> i32 { <i32 as Default>::default() }
  :smirk:
  String/
  i32are just an exemplification, Do you think writing macros for every type
  Twould be a good idea? BTW, am OK with
  Default::default(). I've not looked at the macro part yet.
  use that_crate::Alias::somethingwork (only guessing)?
  I'm sorry for the silly question, but I've been away from Rust for a bit and struggling to settle back in. How do I important a crate that is a "sub-crate" of another? So crate Foo's cargo manifest dir has a subdir with another crate, Bar. In Foo, there is a file, lib.rs, which includes the line "pub extern crate Bar as Alias;"
  Foo's
  Cargo.toml:
  [dependencies] Bar = { path = "./Bar" }
  In
  Foo's
  lib.rs:
  pub extern crate Bar as Alias; ...
  usewhichever specific parts of Bar you need through Foo::Alias.
  use Foo::Alias as Bar;