MCPcopy Create free account
hub / github.com/CSpyridakis/notes / tupples

Function tupples

Rust/notes.rs:728–750  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

726
727
728fn tupples(){ // Fixed size ordered list of elements of different(or same) data types
729 // Tuples are also immutable by default and even with mut, its element count cannot be changed.
730 // Also, if you want to change an element’s value, the new value should have the same data type of previous value.
731
732 println!("\n======================================================================");
733 println!("* TUPPLES: (Fixed size ordered list of elements of different(or same) data types)");
734
735
736 let a = (1, 1.5, true, 'a'); // Declaration + assignment; without data type
737 pvar!(a);
738 let a: (i32, f64, bool, char) = (1, 1.5, true, 'a'); // Declaration + assignment; with data type
739
740 let mut mut_tupple = (1, 1.5); // Mutable tupple
741 mut_tupple.0 = 2; // Access tupple values via tuple indexing
742 mut_tupple.1 = 3.0;
743
744 let (c, d) = mut_tupple; // To variables <= from tupple
745 let (e, _, _, f) = a; // variables <= from tupple, and also not use some values
746 let single_element_tupple = (0,); // Single-element tuple
747 let nested_tupple = (mut_tupple, (2, 4), 5); // Nested tupples
748
749 pvar!(a, mut_tupple, c, d, e, f, single_element_tupple, nested_tupple);
750}
751
752
753fn slices(){

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected