@@ -8,6 +8,9 @@ use core::ops::{IndexMut, Range};
8
8
use core:: panic:: { RefUnwindSafe , UnwindSafe } ;
9
9
use core:: slice:: { self , SliceIndex } ;
10
10
11
+ #[ cfg( feature = "block" ) ]
12
+ use objc2:: rc:: IdFromIterator ;
13
+
11
14
use crate :: common:: * ;
12
15
#[ cfg( feature = "Foundation_NSMutableData" ) ]
13
16
use crate :: Foundation :: NSMutableData ;
@@ -246,18 +249,22 @@ impl std::io::Write for NSMutableData {
246
249
}
247
250
}
248
251
249
- // #[cfg(feature = "Foundation_NSMutableData")]
250
- // impl FromIterator<u8> for Id<NSMutableData> {
251
- // fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self {
252
- // let iter = iter.into_iter();
253
- // let (lower, _) = iter.size_hint();
254
- // let data = Self::with_capacity(lower);
255
- // for item in iter {
256
- // data.push(item);
257
- // }
258
- // data
259
- // }
260
- // }
252
+ #[ cfg( feature = "block" ) ]
253
+ impl IdFromIterator < u8 > for NSData {
254
+ fn id_from_iter < I : IntoIterator < Item = u8 > > ( iter : I ) -> Id < Self > {
255
+ let vec = Vec :: from_iter ( iter) ;
256
+ Self :: from_vec ( vec)
257
+ }
258
+ }
259
+
260
+ #[ cfg( feature = "Foundation_NSMutableData" ) ]
261
+ #[ cfg( feature = "block" ) ]
262
+ impl IdFromIterator < u8 > for NSMutableData {
263
+ fn id_from_iter < I : IntoIterator < Item = u8 > > ( iter : I ) -> Id < Self > {
264
+ let vec = Vec :: from_iter ( iter) ;
265
+ Self :: from_vec ( vec)
266
+ }
267
+ }
261
268
262
269
#[ cfg( feature = "block" ) ]
263
270
unsafe fn with_vec < T : Message > ( obj : Option < Allocated < T > > , bytes : Vec < u8 > ) -> Id < T > {
0 commit comments