Ajout d’un stringer sur option.Result (à des fins de debug)
This commit is contained in:
		
							parent
							
								
									c4029042e0
								
							
						
					
					
						commit
						46731e79d8
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,9 @@
 | 
			
		|||
package option
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Result stocke un résultat :
 | 
			
		||||
// - soit le résultat est valide, et une valeur est stockée,
 | 
			
		||||
// - soit le résultat est invalide, et une erreur est stockée.
 | 
			
		||||
| 
						 | 
				
			
			@ -41,3 +45,11 @@ func (r Result[T]) Err() (err error, ok bool) {
 | 
			
		|||
func (r Result[T]) IsOk() bool {
 | 
			
		||||
	return r.ok
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r Result[T]) String() string {
 | 
			
		||||
	return fmt.Sprintf(`{
 | 
			
		||||
  value: %v,
 | 
			
		||||
  error: %s,
 | 
			
		||||
  ok: %v,
 | 
			
		||||
	}`, r.v, r.err, r.ok)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue