Does Rust have syntax for initializing a struct field with an earlier field? -


example code, not compile:

pub struct s {     pub a: int,     pub b: int }  impl s {     pub fn new(input: int) -> s {         s { a: input + 1, b: }     } } 

the b: a bit isn't valid syntax, there way in current rust? [rustc 0.13.0-nightly (eedfc0779 2014-11-25 22:36:59 +0000)]

obviously repeat input + 1 or use temporary variable, i'm curious using already-initialized field input field.

no, there not that, nor reasonable expect there ever be; rust’s ownership semantics make of little value apply copy types well, references too.

the alternatives simple complicating language such feature pretty guaranteed not happen.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -