hyperion101010

Untitled

Dec 30th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. hyperion@hyperion:~/rust_material/playground/src$ more main.rs
  2. extern crate rand;
  3.  
  4. use std::io;
  5. use std::cmp::Ordering;
  6. use rand::Rng;
  7.  
  8.  
  9. fn main() {
  10. let a = 5;
  11. if a>10{
  12. println!("true");
  13. }
  14. else {
  15. println!("false");
  16. }
  17. }
  18.  
  19. fn display_p(arr : [i32;5]) {
  20. let a = {
  21. let b : i32 = 32;
  22. };
  23. println!("{}",a)
  24. }
  25.  
  26. /*
  27. let er : (i32,f32,char)=(23,23.0,'');
  28. printn;
  29.  
  30. match a.cmp(&b)
  31. {
  32. Ordering::Less => println(),
  33. Ordering::Greater =>,
  34.  
  35. }
  36. let a : u32 ="42".len().expect("bot a number");;
  37.  
  38. let mut a: u32 =String.new().trim().parse();
  39.  
  40. data types are as
  41. i8;i16;164
  42. u64,u32;
  43. isize depends on the architecture
  44. usize depends on the arch
  45. rust floating types are defined as
  46. f32 as 32 bit
  47. f64 as 64 bit
  48. let f :bool = false;
  49. char is the most basic and is thus used as it is
  50. let a = 'a';
  51.  
  52. */
  53.  
  54.  
  55. hyperion@hyperion:~/rust_material/playground/src$ cargo run
  56. Compiling playground v0.1.0 (/home/hyperion/rust_material/playground)
  57. warning: unused import: `std::io`
  58. --> src/main.rs:3:5
  59. |
  60. 3 | use std::io;
  61. | ^^^^^^^
  62. |
  63. = note: #[warn(unused_imports)] on by default
  64.  
  65. warning: unused import: `std::cmp::Ordering`
  66. --> src/main.rs:4:5
  67. |
  68. 4 | use std::cmp::Ordering;
  69. | ^^^^^^^^^^^^^^^^^^
  70.  
  71. warning: unused import: `rand::Rng`
  72. --> src/main.rs:5:5
  73. |
  74. 5 | use rand::Rng;
  75. | ^^^^^^^^^
  76.  
  77. error[E0277]: `()` doesn't implement `std::fmt::Display`
  78. --> src/main.rs:22:19
  79. |
  80. 22 | println!("{}",a)
  81. | ^ `()` cannot be formatted with the default formatter
  82. |
  83. = help: the trait `std::fmt::Display` is not implemented for `()`
  84. = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
  85. = note: required by `std::fmt::Display::fmt`
  86.  
  87. error: aborting due to previous error
  88.  
  89. For more information about this error, try `rustc --explain E0277`.
  90. error: Could not compile `playground`.
  91.  
  92. To learn more, run the command again with --verbose.
Add Comment
Please, Sign In to add comment