Skip to content

WIP: Try to retain location #5

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ hashlink = "0.8"
[dev-dependencies]
quickcheck = "1.0"

[lib]
doctest = false

[profile.release-lto]
inherits = "release"
lto = true
4 changes: 2 additions & 2 deletions examples/dump_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ fn print_indent(indent: usize) {

fn dump_node(doc: &yaml::Yaml, indent: usize) {
match *doc {
yaml::Yaml::Array(ref v) => {
yaml::Yaml::Array(ref v, _) => {
for x in v {
dump_node(x, indent + 1);
}
}
yaml::Yaml::Hash(ref h) => {
yaml::Yaml::Hash(ref h, _) => {
for (k, v) in h {
print_indent(indent);
println!("{k:?}:");
Expand Down
18 changes: 9 additions & 9 deletions src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ impl<'a> YamlEmitter<'a> {

fn emit_node(&mut self, node: &Yaml) -> EmitResult {
match *node {
Yaml::Array(ref v) => self.emit_array(v),
Yaml::Hash(ref h) => self.emit_hash(h),
Yaml::String(ref v) => {
Yaml::Array(ref v, _) => self.emit_array(v),
Yaml::Hash(ref h, _) => self.emit_hash(h),
Yaml::String(ref v, _) => {
if self.multiline_strings
&& v.contains('\n')
&& char_traits::is_valid_literal_block_scalar(v)
Expand All @@ -235,19 +235,19 @@ impl<'a> YamlEmitter<'a> {
}
Ok(())
}
Yaml::Boolean(v) => {
Yaml::Boolean(v, _) => {
if v {
self.writer.write_str("true")?;
} else {
self.writer.write_str("false")?;
}
Ok(())
}
Yaml::Integer(v) => {
Yaml::Integer(v, _) => {
write!(self.writer, "{v}")?;
Ok(())
}
Yaml::Real(ref v) => {
Yaml::Real(ref v, _) => {
write!(self.writer, "{v}")?;
Ok(())
}
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<'a> YamlEmitter<'a> {
} else {
self.level += 1;
for (cnt, (k, v)) in h.iter().enumerate() {
let complex_key = matches!(*k, Yaml::Hash(_) | Yaml::Array(_));
let complex_key = matches!(*k, Yaml::Hash(_, _) | Yaml::Array(_, _));
if cnt > 0 {
writeln!(self.writer)?;
self.write_indent()?;
Expand Down Expand Up @@ -313,7 +313,7 @@ impl<'a> YamlEmitter<'a> {
/// and short enough to respect the compact flag.
fn emit_val(&mut self, inline: bool, val: &Yaml) -> EmitResult {
match *val {
Yaml::Array(ref v) => {
Yaml::Array(ref v, _) => {
if (inline && self.compact) || v.is_empty() {
write!(self.writer, " ")?;
} else {
Expand All @@ -324,7 +324,7 @@ impl<'a> YamlEmitter<'a> {
}
self.emit_array(v)
}
Yaml::Hash(ref h) => {
Yaml::Hash(ref h, _) => {
if (inline && self.compact) || h.is_empty() {
write!(self.writer, " ")?;
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/fixtures/multiline_string.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a: |-
this is a long
string over
3 lines
b: just short...
c:
d:
e: "Great!"
Loading