Skip to content

Commit

Permalink
Upgrade tempfile 2.x.x -> 3.x.x (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
repi authored and mitsuhiko committed May 16, 2019
1 parent f7b2026 commit c4a6cf9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -8,7 +8,8 @@ license = "MIT"
homepage = "https://github.com/mitsuhiko/dialoguer"
documentation = "https://docs.rs/dialoguer"
readme = "README.md"

[dependencies]
console = ">=0.3.0, <1.0.0"
lazy_static = "1"
tempfile = "2"
tempfile = "3"
6 changes: 2 additions & 4 deletions src/edit.rs
Expand Up @@ -5,8 +5,6 @@ use std::io;
use std::io::{Read, Write};
use std::process;

use tempfile::NamedTempFileOptions;

/// Launches the default editor edit a string.
///
/// Example:
Expand Down Expand Up @@ -86,11 +84,11 @@ impl Editor {
/// Returns `None` if the file was not saved or otherwise the
/// entered text.
pub fn edit(&self, s: &str) -> io::Result<Option<String>> {
let mut f = NamedTempFileOptions::new()
let mut f = tempfile::Builder::new()
.prefix("edit-")
.suffix(&self.extension)
.rand_bytes(12)
.create()?;
.tempfile()?;
f.write_all(s.as_bytes())?;
f.flush()?;
let ts = fs::metadata(f.path())?.modified()?;
Expand Down

0 comments on commit c4a6cf9

Please sign in to comment.