Thanks for feedback!
Ok, lets make partiality looks more Rust-friendly:
- For Structs and Enum Types partiality is written
::{ /*fields */ }
as "use
" declaration
enum E4 {A (i32), B(i32), C (i32), D(i32)}
// for Enums
fn do_eac(e: E4::{A, C}) { /* .. */ }
struct S4 {a : i32, b : i32, c : i32, d : i32}
// for Structs
fn do_sac(s: S4::{a, c}) { /* .. */ }
- For Tuple Types use
%lock
( or lock
) before field instead of unified syntax:
fn do_t23(t: (lock i32, lock &u32, f64, &f32)) { /* .. */ }
// same as
fn do_t23(t: (i32, &u32, f64, &f32)::{2,3}) { /* .. */ }
- For Partial Expression for Struct and Tuples use
.{ /* fields*/ }
syntax, which is similar with "get 1 field" s.x
and Struct declaration "{}
":
let ref_sxy = & s.{x, y};
// same as
let ref_sxy : & S4::{x, y} = & s.{x, y};
- All not fully filed initialization for Structs are Partly Typed:
struct S4 {a : i32, b : i32, c : i32, d : i32}
let sac = S4{a : 5, c : 7};
// sac : S4::{a, c}
- For Tuple Types initialization we could use
%lock
( or lock
) before field instead of unified syntax:
let t23 = ( lock 2i32, lock & 8u32, 6.0f64, 7.0f32);
// t23 : (lock i32, lock &u32, f64, f32)
// same as
// t23 : (i32, &u32, f64, f32)::{2, 3}
- For partial mutability we also use
.{ /* fields*/ }
syntax:
let mut.{a} s = S4{a: 5, b: 7};
let refmut_sa = &mut.{a} s;
Is this look better now?