Skip to content

Commit

Permalink
Wrap rust at 80 columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 20, 2018
1 parent c67d98e commit a7bf154
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ extern "C" {
js_source: *const c_char,
) -> c_int;
pub fn deno_handle_msg_from_js(d: *const DenoC, buf: deno_buf);
pub fn deno_reply_error(d: *const DenoC, cmd_id: uint32_t, msg: *const c_char);
pub fn deno_reply_error(
d: *const DenoC,
cmd_id: uint32_t,
msg: *const c_char,
);
pub fn deno_reply_null(d: *const DenoC, cmd_id: uint32_t);
pub fn deno_reply_code_fetch(
d: *const DenoC,
Expand Down
6 changes: 4 additions & 2 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ fn test_resolve_module() {
for &test in test_cases.iter() {
let module_specifier = String::from(test.0);
let containing_file = String::from(test.1);
let (module_name, filename) = resolve_module(&module_specifier, &containing_file).unwrap();
let (module_name, filename) =
resolve_module(&module_specifier, &containing_file).unwrap();
assert_eq!(module_name, test.2);
assert_eq!(filename, test.3);
}
Expand All @@ -184,7 +185,8 @@ pub extern "C" fn handle_code_fetch(
let result = resolve_module(&module_specifier, &containing_file);
if result.is_err() {
let err = result.unwrap_err();
let errmsg = format!("{} {} {}", err, module_specifier, containing_file);
let errmsg =
format!("{} {} {}", err, module_specifier, containing_file);
let errmsg_c = as_cstring(&errmsg);
unsafe { deno_reply_error(d, cmd_id, errmsg_c.as_ptr()) };
return;
Expand Down
16 changes: 12 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use std::ffi::CString;
use std::ptr;

mod binding;
use binding::{deno_delete, deno_execute, deno_handle_msg_from_js, deno_init, deno_last_exception,
deno_new, deno_set_flags, DenoC};
use binding::{
deno_delete, deno_execute, deno_handle_msg_from_js, deno_init,
deno_last_exception, deno_new, deno_set_flags, DenoC,
};

// Pass the command line arguments to v8.
// Returns a vector of command line arguments that v8 did not understand.
Expand Down Expand Up @@ -58,10 +60,16 @@ impl Deno {
Deno { ptr: ptr }
}

fn execute(&mut self, js_filename: &str, js_source: &str) -> Result<(), DenoException> {
fn execute(
&mut self,
js_filename: &str,
js_source: &str,
) -> Result<(), DenoException> {
let filename = CString::new(js_filename).unwrap();
let source = CString::new(js_source).unwrap();
let r = unsafe { deno_execute(self.ptr, filename.as_ptr(), source.as_ptr()) };
let r = unsafe {
deno_execute(self.ptr, filename.as_ptr(), source.as_ptr())
};
if r == 0 {
let ptr = unsafe { deno_last_exception(self.ptr) };
let cstr = unsafe { CStr::from_ptr(ptr) };
Expand Down
8 changes: 6 additions & 2 deletions tools/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
third_party_path = os.path.join(root_path, "third_party")
prettier = os.path.join(third_party_path, "node_modules", "prettier",
"bin-prettier.js")
tools_path = os.path.join(root_path, "tools")
rustfmt_config = os.path.join(tools_path, "rustfmt.toml")

os.chdir(root_path)
# TODO(ry) Install clang-format in third_party.
Expand All @@ -24,5 +26,7 @@
rustfmt_extra_args = []
if 'RUSTFMT_FLAGS' in os.environ:
rustfmt_extra_args += os.environ['RUSTFMT_FLAGS'].split()
run(["rustfmt", "--write-mode", "overwrite"] + rustfmt_extra_args +
glob("src/*.rs"))
run([
"rustfmt", "--config-path", rustfmt_config, "--error-on-unformatted",
"--write-mode", "overwrite"
] + rustfmt_extra_args + glob("src/*.rs"))
1 change: 1 addition & 0 deletions tools/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
max_width = 80

0 comments on commit a7bf154

Please sign in to comment.