@@ -192,6 +192,10 @@ impl FileDescription for NullOutput {
192
192
pub struct FileDescriptor ( Rc < RefCell < Box < dyn FileDescription > > > ) ;
193
193
194
194
impl FileDescriptor {
195
+ fn new ( fd : impl FileDescription ) -> Self {
196
+ FileDescriptor ( Rc :: new ( RefCell :: new ( Box :: new ( fd) ) ) )
197
+ }
198
+
195
199
pub fn borrow ( & self ) -> Ref < ' _ , dyn FileDescription > {
196
200
Ref :: map ( self . 0 . borrow ( ) , |fd| fd. as_ref ( ) )
197
201
}
@@ -239,14 +243,14 @@ impl FdTable {
239
243
fds
240
244
}
241
245
242
- /// Insert a file descriptor to the FdTable.
243
- pub fn insert_fd < T : FileDescription > ( & mut self , fd : T ) -> i32 {
244
- let file_handle = FileDescriptor ( Rc :: new ( RefCell :: new ( Box :: new ( fd ) ) ) ) ;
246
+ /// Insert a new file description to the FdTable.
247
+ pub fn insert_fd ( & mut self , fd : impl FileDescription ) -> i32 {
248
+ let file_handle = FileDescriptor :: new ( fd ) ;
245
249
self . insert_fd_with_min_fd ( file_handle, 0 )
246
250
}
247
251
248
252
/// Insert a new FD that is at least `min_fd`.
249
- pub fn insert_fd_with_min_fd ( & mut self , file_handle : FileDescriptor , min_fd : i32 ) -> i32 {
253
+ fn insert_fd_with_min_fd ( & mut self , file_handle : FileDescriptor , min_fd : i32 ) -> i32 {
250
254
// Find the lowest unused FD, starting from min_fd. If the first such unused FD is in
251
255
// between used FDs, the find_map combinator will return it. If the first such unused FD
252
256
// is after all other used FDs, the find_map combinator will return None, and we will use
0 commit comments