Skip to content

Commit

Permalink
Unwrap log lines
Browse files Browse the repository at this point in the history
  • Loading branch information
neersighted committed Apr 1, 2018
1 parent b32002d commit 39d95ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-g"
version = "0.1.3"
version = "0.2.0"
authors = ["Bjorn Neergaard <[email protected]>"]

[lib]
Expand Down
3 changes: 1 addition & 2 deletions src/byond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ thread_local! {

pub fn parse_args<'a>(argc: c_int, argv: *const *const c_char) -> Vec<Cow<'a, str>> {
unsafe {
slice::from_raw_parts(argv, argc as usize)
.into_iter()
slice::from_raw_parts(argv, argc as usize).into_iter()
.map(|ptr| CStr::from_ptr(*ptr))
.map(|cstr| cstr.to_string_lossy())
.collect()
Expand Down
9 changes: 6 additions & 3 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ fn close() {
});
}

byond_function! { log_write(filename, line) {
let line = timestamped(line);
match write(filename, line) {
byond_function! { log_write(filename, data) {
let results: Result<Vec<_>, Error> = data.split("\n")
.map(|line| write(filename, timestamped(line)))
.collect();

match results {
Ok(_) => None,
Err(err) => Some(err.to_string()),
}
Expand Down

0 comments on commit 39d95ad

Please sign in to comment.