Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. use std::io::{Result, Error};
  2.  
  3. fn main() {
  4. let vec: Vec<Result<()>> = vec![];
  5. let val: Result<Vec<()>> = vec.iter().collect();
  6.  
  7. println!("{:?}", val);
  8. }
  9.  
  10.  
  11.  
  12.  
  13.  
  14. //pub fn vec() -> Vec<u32> {
  15. // (0..).take(1024 * 32).collect()
  16. //}
  17.  
  18. /*const length: usize = 1024 * 32;
  19. pub fn slice() -> [u32; length] {
  20. (0..)
  21. .zip(0..length)
  22. .fold([0; length], |mut acc, (num, idx)| {
  23. acc[idx] = num;
  24. acc
  25. })
  26. } */
  27.  
  28. /* use delegate;
  29.  
  30. // The `delegate::setup!(...)` call is only a data container
  31. #[delegate::gen]
  32. delegate::setup!(NetworkHandler<T>, {
  33. Network {
  34. send -> ( &self, &[u8] ) => inner,
  35. receive -> ( &self ) -> (usize, &[u8]) => inner,
  36. }
  37. });
  38.  
  39. /*
  40. * Let's look at what information is required to generate the following code
  41. */
  42.  
  43. // T is taken from NetworkHandler<T> parsing
  44. impl<T> Network for NetworkHandler<T> {
  45.  
  46. // &self is magic
  47. // -> basically &self, self and &mut self are parsed seperately
  48. // and are not included in the parameter list of the called function
  49. // all other parameters get an id assigned (here `a`)
  50. fn send(&self, a: &[u8]) {
  51. self.inner.send(a) // Call function with only id names
  52. }
  53.  
  54. // Again, self is magic
  55. fn receive(&self) -> (usize, &[u8]) {
  56. self.inner.receive()
  57. }
  58. }
  59. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement