mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 05:48:56 +08:00 
			
		
		
		
	Add Rows::{mapped,and_then} to get an Iterator out of a Rows i… (#676)
				
					
				
			This commit is contained in:
		
							
								
								
									
										19
									
								
								src/row.rs
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/row.rs
									
									
									
									
									
								
							| @@ -41,6 +41,25 @@ impl<'stmt> Rows<'stmt> { | ||||
|     { | ||||
|         Map { rows: self, f } | ||||
|     } | ||||
|  | ||||
|     /// Map over this `Rows`, converting it to a [`MappedRows`], which | ||||
|     /// implements `Iterator`. | ||||
|     pub fn mapped<F, B>(self, f: F) -> MappedRows<'stmt, F> | ||||
|     where | ||||
|         F: FnMut(&Row<'_>) -> Result<B>, | ||||
|     { | ||||
|         MappedRows { rows: self, map: f } | ||||
|     } | ||||
|  | ||||
|     /// Map over this `Rows` with a fallible function, converting it to a | ||||
|     /// [`AndThenRows`], which implements `Iterator` (instead of | ||||
|     /// `FallibleStreamingIterator`). | ||||
|     pub fn and_then<F, T, E>(self, f: F) -> AndThenRows<'stmt, F> | ||||
|     where | ||||
|         F: FnMut(&Row<'_>) -> result::Result<T, E>, | ||||
|     { | ||||
|         AndThenRows { rows: self, map: f } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<'stmt> Rows<'stmt> { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user