Skip to content

Commit e48369c

Browse files
committed
Rename util module to defer
1 parent df4f383 commit e48369c

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/util.rs renamed to src/defer.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
/*!
2-
This module just contains other random implementation stuff.
3-
*/
1+
//! This module contains an implementation of Defer.
42
use log::error;
53
use std::error::Error;
64
use std::marker::PhantomData;
75

8-
/**
9-
Used to defer a closure until the value is dropped.
10-
11-
The closure *must* return a `Result<(), _>`, as a reminder to *not* panic; doing so will abort your whole program if it happens during another panic. If the closure returns an `Err`, then it is logged as an `error`.
12-
13-
A `Defer` can also be "disarmed", preventing the closure from running at all.
14-
*/
6+
/// Used to defer a closure until the value is dropped.
7+
///
8+
/// The closure *must* return a `Result<(), _>`, as a reminder to *not* panic; doing so will abort your whole program if it happens during another panic. If the closure returns an `Err`, then it is logged as an `error`.
9+
///
10+
/// A `Defer` can also be "disarmed", preventing the closure from running at all.
1511
#[must_use]
1612
pub struct Defer<'a, F, E>(Option<F>, PhantomData<&'a F>)
1713
where
@@ -23,16 +19,12 @@ where
2319
F: 'a + FnOnce() -> Result<(), E>,
2420
E: Error,
2521
{
26-
/**
27-
Create a new `Defer` with the given closure.
28-
*/
22+
/// Create a new `Defer` with the given closure.
2923
pub fn new(f: F) -> Defer<'a, F, E> {
3024
Defer(Some(f), PhantomData)
3125
}
3226

33-
/**
34-
Consume this `Defer` *without* invoking the closure.
35-
*/
27+
/// Consume this `Defer` *without* invoking the closure.
3628
pub fn disarm(mut self) {
3729
self.0 = None;
3830
drop(self);

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
mod arguments;
44
mod build_kind;
55
mod consts;
6+
mod defer;
67
mod error;
78
mod manifest;
89
mod platform;
910
mod templates;
10-
mod util;
1111

1212
#[cfg(windows)]
1313
mod file_assoc;
@@ -27,8 +27,8 @@ use std::path::{Path, PathBuf};
2727
use std::process::Command;
2828

2929
use crate::build_kind::BuildKind;
30+
use crate::defer::Defer;
3031
use crate::error::{MainError, MainResult};
31-
use crate::util::Defer;
3232
use sha1::{Digest, Sha1};
3333

3434
fn main() {

0 commit comments

Comments
 (0)