Skip to content

Commit 8b2d367

Browse files
committed
breaking: Rename EventLoop::try_new to new
So this is how it begins. Signed-off-by: John Nunley <[email protected]>
1 parent ba9ed53 commit 8b2d367

File tree

19 files changed

+69
-69
lines changed

19 files changed

+69
-69
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
// just annotate the type here; the actual data is provided later in the
3737
// run() call.
3838
let mut event_loop: EventLoop<LoopSignal> =
39-
EventLoop::try_new().expect("Failed to initialize the event loop!");
39+
EventLoop::new().expect("Failed to initialize the event loop!");
4040

4141
// Retrieve a handle. It is used to insert new sources into the event loop
4242
// It can be cloned, allowing you to insert sources from within source

benches/timer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use calloop::timer::TimeoutAction;
44
use criterion::{criterion_group, criterion_main, Criterion};
55

66
fn single(c: &mut Criterion) {
7-
let mut event_loop = calloop::EventLoop::<()>::try_new().unwrap();
7+
let mut event_loop = calloop::EventLoop::<()>::new().unwrap();
88
let loop_handle = event_loop.handle();
99

1010
let timer = calloop::timer::Timer::from_duration(Duration::from_secs(60 * 10));
@@ -27,7 +27,7 @@ fn single(c: &mut Criterion) {
2727
}
2828

2929
fn mixed(c: &mut Criterion) {
30-
let mut event_loop = calloop::EventLoop::<()>::try_new().unwrap();
30+
let mut event_loop = calloop::EventLoop::<()>::new().unwrap();
3131
let loop_handle = event_loop.handle();
3232

3333
let timer = calloop::timer::Timer::from_duration(Duration::from_secs(60 * 10 - 1));
@@ -60,7 +60,7 @@ fn mixed(c: &mut Criterion) {
6060
}
6161

6262
fn mixed_multiple(c: &mut Criterion) {
63-
let mut event_loop = calloop::EventLoop::<()>::try_new().unwrap();
63+
let mut event_loop = calloop::EventLoop::<()>::new().unwrap();
6464
let loop_handle = event_loop.handle();
6565

6666
for _ in 0..1000 {

doc/src/adapt_io_example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() -> std::io::Result<()> {
1111
// ANCHOR_END: decl_executor
1212

1313
// ANCHOR: decl_loop
14-
let mut event_loop = EventLoop::try_new()?;
14+
let mut event_loop = EventLoop::new()?;
1515
let handle = event_loop.handle();
1616

1717
handle

doc/src/async_example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() -> std::io::Result<()> {
1111
// ANCHOR_END: decl_executor
1212

1313
// ANCHOR: decl_loop
14-
let mut event_loop = EventLoop::try_new()?;
14+
let mut event_loop = EventLoop::new()?;
1515
let handle = event_loop.handle();
1616

1717
handle

doc/src/timer_example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use calloop::{
77
};
88

99
fn main() {
10-
let mut event_loop = EventLoop::try_new().expect("Failed to initialize the event loop!");
10+
let mut event_loop = EventLoop::new().expect("Failed to initialize the event loop!");
1111

1212
// ANCHOR: decl_source
1313
let timer = Timer::from_duration(Duration::from_secs(5));

examples/high_precision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use calloop::{
77

88
fn main() {
99
// As of calloop v0.11 there is no difference between low and high precision event loops.
10-
let mut event_loop = EventLoop::try_new().expect("Failed to initialize the event loop!");
10+
let mut event_loop = EventLoop::new().expect("Failed to initialize the event loop!");
1111

1212
let before = Instant::now();
1313

examples/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() {
1111
// just annotate the type here; the actual data is provided later in the
1212
// run() call.
1313
let mut event_loop: EventLoop<LoopSignal> =
14-
EventLoop::try_new().expect("Failed to initialize the event loop!");
14+
EventLoop::new().expect("Failed to initialize the event loop!");
1515

1616
// Retrieve a handle. It is used to insert new sources into the event loop
1717
// It can be cloned, allowing you to insert sources from within source

src/io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ mod tests {
415415

416416
#[test]
417417
fn read_write() {
418-
let mut event_loop = crate::EventLoop::try_new().unwrap();
418+
let mut event_loop = crate::EventLoop::new().unwrap();
419419
let handle = event_loop.handle();
420420
let (exec, sched) = executor().unwrap();
421421
handle
@@ -460,7 +460,7 @@ mod tests {
460460

461461
#[test]
462462
fn read_write_vectored() {
463-
let mut event_loop = crate::EventLoop::try_new().unwrap();
463+
let mut event_loop = crate::EventLoop::new().unwrap();
464464
let handle = event_loop.handle();
465465
let (exec, sched) = executor().unwrap();
466466
handle
@@ -515,7 +515,7 @@ mod tests {
515515
fn readable() {
516516
use std::io::Write;
517517

518-
let mut event_loop = crate::EventLoop::try_new().unwrap();
518+
let mut event_loop = crate::EventLoop::new().unwrap();
519519
let handle = event_loop.handle();
520520
let (exec, sched) = executor().unwrap();
521521
handle
@@ -554,7 +554,7 @@ mod tests {
554554
fn writable() {
555555
use std::io::{BufReader, BufWriter, Read, Write};
556556

557-
let mut event_loop = crate::EventLoop::try_new().unwrap();
557+
let mut event_loop = crate::EventLoop::new().unwrap();
558558
let handle = event_loop.handle();
559559
let (exec, sched) = executor().unwrap();
560560
handle

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//! // just annotate the type here; the actual data is provided later in the
3131
//! // run() call.
3232
//! let mut event_loop: EventLoop<LoopSignal> =
33-
//! EventLoop::try_new().expect("Failed to initialize the event loop!");
33+
//! EventLoop::new().expect("Failed to initialize the event loop!");
3434
//!
3535
//! // Retrieve a handle. It is used to insert new sources into the event loop
3636
//! // It can be cloned, allowing you to insert sources from within source

src/loop_logic.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl<'l, Data> EventLoop<'l, Data> {
379379
/// Create a new event loop
380380
///
381381
/// Fails if the initialization of the polling system failed.
382-
pub fn try_new() -> crate::Result<Self> {
382+
pub fn new() -> crate::Result<Self> {
383383
let poll = Poll::new()?;
384384
let poller = poll.poller.clone();
385385
let handle = LoopHandle {
@@ -842,7 +842,7 @@ mod tests {
842842

843843
#[test]
844844
fn dispatch_idle() {
845-
let mut event_loop = EventLoop::try_new().unwrap();
845+
let mut event_loop = EventLoop::new().unwrap();
846846

847847
let mut dispatched = false;
848848

@@ -859,7 +859,7 @@ mod tests {
859859

860860
#[test]
861861
fn cancel_idle() {
862-
let mut event_loop = EventLoop::try_new().unwrap();
862+
let mut event_loop = EventLoop::new().unwrap();
863863

864864
let mut dispatched = false;
865865

@@ -879,7 +879,7 @@ mod tests {
879879

880880
#[test]
881881
fn wakeup() {
882-
let mut event_loop = EventLoop::try_new().unwrap();
882+
let mut event_loop = EventLoop::new().unwrap();
883883

884884
let signal = event_loop.get_signal();
885885

@@ -894,7 +894,7 @@ mod tests {
894894

895895
#[test]
896896
fn wakeup_stop() {
897-
let mut event_loop = EventLoop::try_new().unwrap();
897+
let mut event_loop = EventLoop::new().unwrap();
898898

899899
let signal = event_loop.get_signal();
900900

@@ -910,7 +910,7 @@ mod tests {
910910

911911
#[test]
912912
fn additional_events() {
913-
let mut event_loop: EventLoop<'_, Lock> = EventLoop::try_new().unwrap();
913+
let mut event_loop: EventLoop<'_, Lock> = EventLoop::new().unwrap();
914914
let mut lock = Lock {
915915
lock: Rc::new((
916916
// Whether the lock is locked
@@ -1045,7 +1045,7 @@ mod tests {
10451045
fn default_additional_events() {
10461046
let (sender, channel) = channel();
10471047
let mut test_source = NoopWithDefaultHandlers { channel };
1048-
let mut event_loop = EventLoop::try_new().unwrap();
1048+
let mut event_loop = EventLoop::new().unwrap();
10491049
event_loop
10501050
.handle()
10511051
.insert_source(Box::new(&mut test_source), |_, _, _| {})
@@ -1103,7 +1103,7 @@ mod tests {
11031103

11041104
#[test]
11051105
fn additional_events_synthetic() {
1106-
let mut event_loop: EventLoop<'_, Lock> = EventLoop::try_new().unwrap();
1106+
let mut event_loop: EventLoop<'_, Lock> = EventLoop::new().unwrap();
11071107
let mut lock = Lock {
11081108
lock: Rc::new(Cell::new(false)),
11091109
};
@@ -1212,7 +1212,7 @@ mod tests {
12121212
}
12131213
}
12141214

1215-
let event_loop = EventLoop::<()>::try_new().unwrap();
1215+
let event_loop = EventLoop::<()>::new().unwrap();
12161216
let fd = LeakedFd(ManuallyDrop::new(unsafe {
12171217
std::os::unix::io::OwnedFd::from_raw_fd(420)
12181218
}));
@@ -1227,7 +1227,7 @@ mod tests {
12271227
fn invalid_token() {
12281228
let (_ping, source) = crate::sources::ping::make_ping().unwrap();
12291229

1230-
let event_loop = EventLoop::<()>::try_new().unwrap();
1230+
let event_loop = EventLoop::<()>::new().unwrap();
12311231
let handle = event_loop.handle();
12321232
let reg_token = handle.insert_source(source, |_, _, _| {}).unwrap();
12331233
handle.remove(reg_token);
@@ -1247,7 +1247,7 @@ mod tests {
12471247
let source = crate::sources::generic::Generic::new(read, Interest::EMPTY, Mode::Level);
12481248
let dispatcher = Dispatcher::new(source, |_, _, _| Ok(PostAction::Continue));
12491249

1250-
let event_loop = EventLoop::<()>::try_new().unwrap();
1250+
let event_loop = EventLoop::<()>::new().unwrap();
12511251
let handle = event_loop.handle();
12521252
let ret = handle.register_dispatcher(dispatcher.clone());
12531253

@@ -1262,7 +1262,7 @@ mod tests {
12621262

12631263
#[test]
12641264
fn disarm_rearm() {
1265-
let mut event_loop = EventLoop::<bool>::try_new().unwrap();
1265+
let mut event_loop = EventLoop::<bool>::new().unwrap();
12661266
let (ping, ping_source) = make_ping().unwrap();
12671267

12681268
let ping_token = event_loop
@@ -1353,7 +1353,7 @@ mod tests {
13531353
}
13541354
}
13551355

1356-
let mut event_loop = EventLoop::<u32>::try_new().unwrap();
1356+
let mut event_loop = EventLoop::<u32>::new().unwrap();
13571357

13581358
let (ping1, source1) = make_ping().unwrap();
13591359
let (ping2, source2) = make_ping().unwrap();
@@ -1399,7 +1399,7 @@ mod tests {
13991399
fn change_interests() {
14001400
use rustix::io::write;
14011401
use rustix::net::{recv, socketpair, AddressFamily, RecvFlags, SocketFlags, SocketType};
1402-
let mut event_loop = EventLoop::<bool>::try_new().unwrap();
1402+
let mut event_loop = EventLoop::<bool>::new().unwrap();
14031403

14041404
let (sock1, sock2) = socketpair(
14051405
AddressFamily::UNIX,
@@ -1485,7 +1485,7 @@ mod tests {
14851485

14861486
#[test]
14871487
fn kill_source() {
1488-
let mut event_loop = EventLoop::<Option<RegistrationToken>>::try_new().unwrap();
1488+
let mut event_loop = EventLoop::<Option<RegistrationToken>>::new().unwrap();
14891489

14901490
let handle = event_loop.handle();
14911491
let (ping, ping_source) = make_ping().unwrap();
@@ -1517,7 +1517,7 @@ mod tests {
15171517
struct RefSender<'a>(&'a mpsc::Sender<()>);
15181518
let mut ref_sender = RefSender(&sender);
15191519

1520-
let mut event_loop = EventLoop::<RefSender<'_>>::try_new().unwrap();
1520+
let mut event_loop = EventLoop::<RefSender<'_>>::new().unwrap();
15211521
let (ping, ping_source) = make_ping().unwrap();
15221522
let _ping_token = event_loop
15231523
.handle()
@@ -1544,7 +1544,7 @@ mod tests {
15441544
use crate::sources::timer::TimeoutFuture;
15451545
use std::time::Duration;
15461546

1547-
let mut evl = EventLoop::<()>::try_new().unwrap();
1547+
let mut evl = EventLoop::<()>::new().unwrap();
15481548

15491549
let mut data = 22;
15501550
let timeout = {
@@ -1569,7 +1569,7 @@ mod tests {
15691569
use crate::sources::timer;
15701570
use std::time::Duration;
15711571

1572-
let mut evl = EventLoop::<()>::try_new().unwrap();
1572+
let mut evl = EventLoop::<()>::new().unwrap();
15731573

15741574
let mut data = 22;
15751575
let timeout = {
@@ -1604,7 +1604,7 @@ mod tests {
16041604
use std::sync::{Arc, Mutex};
16051605
use std::time::{Duration, Instant};
16061606

1607-
let mut evl = EventLoop::<RegistrationToken>::try_new().unwrap();
1607+
let mut evl = EventLoop::<RegistrationToken>::new().unwrap();
16081608
let handle = evl.handle();
16091609

16101610
let data = Arc::new(Mutex::new(1));
@@ -1695,7 +1695,7 @@ mod tests {
16951695
}
16961696

16971697
// Now the actual test
1698-
let mut evl = EventLoop::<bool>::try_new().unwrap();
1698+
let mut evl = EventLoop::<bool>::new().unwrap();
16991699
evl.handle()
17001700
.insert_source(WithSubSource { token: None }, |_, _, ran| {
17011701
*ran = true;
@@ -1746,7 +1746,7 @@ mod tests {
17461746

17471747
#[test]
17481748
fn weak_loop_handle() {
1749-
let mut event_loop: EventLoop<()> = EventLoop::try_new().unwrap();
1749+
let mut event_loop: EventLoop<()> = EventLoop::new().unwrap();
17501750
let weak_handle1 = event_loop.handle().downgrade();
17511751
let weak_handle2 = weak_handle1.clone();
17521752
let weak_handle3 = weak_handle1.clone();

0 commit comments

Comments
 (0)