johannhof / pipeline.rs

:umbrella: => :partly_sunny: => :sunny:
Apache License 2.0
249 stars 7 forks source link

Chaining struct methods #5

Open Relrin opened 5 years ago

Relrin commented 5 years ago

Hello,

I've faced with an issue around using your library, when necessary to chain a couple of struct methods together, so that the code looks much better and easier to maintain. The issue raises in code that looks like this:

Box::new(pipe!(
    rabbitmq_client_local.get_channel()
        => self.declare_response_queue
        => self.link_response_queue
        => self.publish_message
        => self.consume_response
        => self.send_response
        => self.unbind_response_queue
        => self.delete_response_queue
        => self.post_process_result
))

Here we see pretty simple code, that contains a RabbitMQ channel and pass it to the nested calls so that each method will produce a new future, based on the previous one.

The piece of code, that was mentioned above, generates the following errors during the compiling stage:

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:165:25                                                                                                                           
    |                                                                                                                                                        
165 |                 => self.declare_response_queue                                                                                                     
    |                        ^                                                                                                                              

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:166:25                                                                                                                           
    |                                                                                                                                                        
166 |                 => self.link_response_queue                                                                                                          
    |                        ^                                                                                                                              

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:167:25                                                                                                                           
    |                                                                                                                                                        
167 |                 => self.publish_message                                                                                                              
    |                        ^                                                                                                                              

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:168:25                                                                                                                           
    |                                                                                                                                                        
168 |                 => self.consume_response                                                                                                            
    |                        ^                                                                                                                              

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:169:25                                                                                                                           
    |                                                                                                                                                        
169 |                 => self.send_response                                                                                                               
    |                        ^                                                                                                                              

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:170:25                                                                                                                           
    |                                                                                                                                                        
170 |                 => self.unbind_response_queue                                                                                                        
    |                        ^                                                                                                                              

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:171:25                                                                                                                           
    |                                                                                                                                                        
171 |                 => self.delete_response_queue                                                                                                    
    |                        ^                                                                                                                              

error: no rules expected the token `.`                                                                                                                       
   --> src/engine/engine.rs:172:25                                                                                                                           
    |                                                                                                                                                        
172 |                 => self.post_process_result                                                                                                        
    |                        ^                                                                                                                              

error: aborting due to 8 previous errors  
piegamesde commented 3 years ago

Try putting the statements into parentheses. Also try replacing the dot with double colons.