On Fri, Apr 13, 2012 at 5:39 AM, Alexander Stavonin
<[email protected]> wrote:
> When we want to create a new record we have to enumerate all fields during 
> creation:
>
> let base = {x: 1, y: 2, z: 3};
>
> This idea is very good, until we are working with small records, without 
> internal subrecords or with low count of field. What is the best way for big 
> records initializing? For example:
>
> type sockaddr4_in = {sin_family: i16, sin_port: u16, sin_addr: in4_addr,
>                     sin_zero: (x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, 
> x, x, x, x, x)};
>
> How to initialize it quick and easy? Idea with using "with" keyword is not 
> too god, as in that case I have to enumerate all fields at list once.
> How about C/C++ style, something like that?
>
> let addr = sockaddr4_in::any_keyword_as_you_like();
> or
> let addr = sockaddr4_in();

What about when the initial values need to be, say, 1 rather than 0,
or "Unknown Name" instead of "", or NaN instead of 0.0f, etc.? Granted
the latter may be slightly more common, but it seems like a hack to
treat it specially just the same, in order to save a tiny bit of
typing to create a "default" record that people can copy from.

-- 
Sebastian Sylvan
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to