Skip to content

Commit

Permalink
adding tidy rule to warn against use of &String and refactoring insta…
Browse files Browse the repository at this point in the history
…nces of &String in codebase
  • Loading branch information
jmr0 committed Nov 26, 2015
1 parent 8efc954 commit df49cf2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions components/net/mime_classifier.rs
Expand Up @@ -129,8 +129,8 @@ impl MIMEClassifier {
}
}

fn get_media_type(media_type: &String,
media_subtype: &String) -> Option<MediaType> {
fn get_media_type(media_type: &str,
media_subtype: &str) -> Option<MediaType> {
if MIMEClassifier::is_xml(media_type, media_subtype) {
Some(MediaType::Xml)
} else if MIMEClassifier::is_html(media_type, media_subtype) {
Expand Down
2 changes: 1 addition & 1 deletion components/profile/mem.rs
Expand Up @@ -225,7 +225,7 @@ impl ReportsTree {

// Searches the tree's children for a path_seg match, and returns the index if there is a
// match.
fn find_child(&self, path_seg: &String) -> Option<usize> {
fn find_child(&self, path_seg: &str) -> Option<usize> {
for (i, child) in self.children.iter().enumerate() {
if child.path_seg == *path_seg {
return Some(i);
Expand Down
8 changes: 4 additions & 4 deletions components/webdriver_server/lib.rs
Expand Up @@ -525,11 +525,11 @@ impl Handler {
}
}

fn handle_element_attribute(&self, element: &WebElement, name: &String) -> WebDriverResult<WebDriverResponse> {
fn handle_element_attribute(&self, element: &WebElement, name: &str) -> WebDriverResult<WebDriverResponse> {
let pipeline_id = try!(self.frame_pipeline());

let (sender, receiver) = ipc::channel().unwrap();
let cmd = WebDriverScriptCommand::GetElementAttribute(element.id.clone(), name.clone(), sender);
let cmd = WebDriverScriptCommand::GetElementAttribute(element.id.clone(), name.to_owned(), sender);
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd);
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
match receiver.recv().unwrap() {
Expand All @@ -539,11 +539,11 @@ impl Handler {
}
}

fn handle_element_css(&self, element: &WebElement, name: &String) -> WebDriverResult<WebDriverResponse> {
fn handle_element_css(&self, element: &WebElement, name: &str) -> WebDriverResult<WebDriverResponse> {
let pipeline_id = try!(self.frame_pipeline());

let (sender, receiver) = ipc::channel().unwrap();
let cmd = WebDriverScriptCommand::GetElementCSS(element.id.clone(), name.clone(), sender);
let cmd = WebDriverScriptCommand::GetElementCSS(element.id.clone(), name.to_owned(), sender);
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd);
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
match receiver.recv().unwrap() {
Expand Down
4 changes: 4 additions & 0 deletions python/tidy.py
Expand Up @@ -369,6 +369,10 @@ def check_rust(file_name, contents):
if ": &Vec<" in line:
yield (idx + 1, "use &[T] instead of &Vec<T>")

# No benefit over using &str
if ": &String" in line:
yield (idx + 1, "use &str instead of &String")


# Avoid flagging <Item=Foo> constructs
def is_associated_type(match, line, index):
Expand Down

0 comments on commit df49cf2

Please sign in to comment.