Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sax build. #7

Merged
merged 1 commit into from Jan 5, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/sax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct Attributes(~[Attribute]);

impl Attributes {
unsafe fn from_buf(atts: **ffi::xmlChar) -> Attributes {
let mut ret = Attributes(~[]);
let mut ret = ~[];
let mut ptr = atts as **c_char;
while !ptr.is_null() && !(*ptr).is_null() {
ret.push(
Expand All @@ -90,13 +90,14 @@ impl Attributes {
);
ptr = ptr.offset(2);
}
ret
Attributes(ret)
}

pub fn find<'a>(&'a self, name: &str) -> Option<&'a str> {
self.iter()
.find(|att| name == att.name)
.map(|att| att.value.as_slice())
let Attributes(ref s) = *self;
s.iter()
.find(|att| name == att.name)
.map(|att| att.value.as_slice())
}

pub fn get<'a>(&'a self, name: &str) -> &'a str {
Expand All @@ -114,7 +115,8 @@ impl Attributes {

impl ToStr for Attributes {
fn to_str(&self) -> ~str {
self.iter().map(|att| {
let Attributes(ref s) = *self;
s.iter().map(|att| {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be (**self).iter().map(|att| {? Would remove the need for the intermediate variable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it returns:

error: single-field tuple-structs can no longer be dereferenced
(**self).iter()

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, ok! Will merge this then.

format!(" {}=\"{}\"", att.name, att.value)
}).to_owned_vec().concat()
}
Expand Down