Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: lib/src/utils.dart

Issue 1944603004: Fix one final strong-mode warning. (Closed) Base URL: git@github.com:dart-lang/http@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/mock_client.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import 'byte_stream.dart'; 9 import 'byte_stream.dart';
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 /// [stream] is done. Unlike [store], [sink] remains open after [stream] is 110 /// [stream] is done. Unlike [store], [sink] remains open after [stream] is
111 /// done. 111 /// done.
112 Future writeStreamToSink(Stream stream, EventSink sink) { 112 Future writeStreamToSink(Stream stream, EventSink sink) {
113 var completer = new Completer(); 113 var completer = new Completer();
114 stream.listen(sink.add, 114 stream.listen(sink.add,
115 onError: sink.addError, 115 onError: sink.addError,
116 onDone: () => completer.complete()); 116 onDone: () => completer.complete());
117 return completer.future; 117 return completer.future;
118 } 118 }
119 119
120 /// Returns a [Future] that asynchronously completes to `null`.
121 Future get async => new Future.value();
122
123 /// A pair of values. 120 /// A pair of values.
124 class Pair<E, F> { 121 class Pair<E, F> {
125 E first; 122 E first;
126 F last; 123 F last;
127 124
128 Pair(this.first, this.last); 125 Pair(this.first, this.last);
129 126
130 String toString() => '($first, $last)'; 127 String toString() => '($first, $last)';
131 128
132 bool operator==(other) { 129 bool operator==(other) {
133 if (other is! Pair) return false; 130 if (other is! Pair) return false;
134 return other.first == first && other.last == last; 131 return other.first == first && other.last == last;
135 } 132 }
136 133
137 int get hashCode => first.hashCode ^ last.hashCode; 134 int get hashCode => first.hashCode ^ last.hashCode;
138 } 135 }
139 136
140 /// Configures [future] so that its result (success or exception) is passed on 137 /// Configures [future] so that its result (success or exception) is passed on
141 /// to [completer]. 138 /// to [completer].
142 void chainToCompleter(Future future, Completer completer) { 139 void chainToCompleter(Future future, Completer completer) {
143 future.then(completer.complete, onError: completer.completeError); 140 future.then(completer.complete, onError: completer.completeError);
144 } 141 }
OLDNEW
« no previous file with comments | « lib/src/mock_client.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698