| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Generic utility functions. Stuff that should possibly be in core. | 6 * Generic utility functions. Stuff that should possibly be in core. |
| 7 */ | 7 */ |
| 8 #library('pub_utils'); | 8 #library('utils'); |
| 9 | 9 |
| 10 /** Thrown by methods that parse text when the text isn't a valid. */ | 10 /** Thrown by methods that parse text when the text isn't a valid. */ |
| 11 class FormatException implements Exception { | 11 class FormatException implements Exception { |
| 12 final String message; | 12 final String message; |
| 13 | 13 |
| 14 FormatException(this.message); | 14 FormatException(this.message); |
| 15 | 15 |
| 16 String toString() => message; | 16 String toString() => message; |
| 17 } | 17 } |
| 18 | 18 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 /** | 63 /** |
| 64 * Asserts that [iter] contains only one element, and returns it. | 64 * Asserts that [iter] contains only one element, and returns it. |
| 65 */ | 65 */ |
| 66 only(Iterable iter) { | 66 only(Iterable iter) { |
| 67 var iterator = iter.iterator(); | 67 var iterator = iter.iterator(); |
| 68 assert(iterator.hasNext()); | 68 assert(iterator.hasNext()); |
| 69 var obj = iterator.next(); | 69 var obj = iterator.next(); |
| 70 assert(!iterator.hasNext()); | 70 assert(!iterator.hasNext()); |
| 71 return obj; | 71 return obj; |
| 72 } | 72 } |
| OLD | NEW |