A few changes have had to be made to `LoadableYamlNode`:
* The `From<Yaml>` requirement has been removed as it can be
error-prone. It was not a direct conversion as it is unable to
handle `Yaml::Hash` or `Yaml::Array` with a non-empty array/map.
* Instead, `from_bare_yaml` was added, which does essentially the same
as `From` but does not leak for users of the library.
* `with_marker` has been added to populate the marker for the `Node`.
The function is empty for `Yaml`.
`load_from_*` methods have been added to `MarkedYaml` for convenience.
They load YAML using the markers.
The markers returned from `saphyr-parser` are not all correct, meaning
that tests are kind of useless for now as they will fail due to bugs
outside of the scope of this library.
This implements the IndexMut trait for Yaml. This allows indexing the
Yaml type while having a mutable reference.
Unlike the Index, this will panic on a failure. That is allowed as per
the Rust documentation [1]. We don't have the option of returning a
mutable reference to BAD_VALUE as that is unsafe. So instead we just
panic.
1: https://doc.rust-lang.org/std/ops/trait.IndexMut.html#tymethod.index_mut
Resolves: https://github.com/chyh1990/yaml-rust/issues/123
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Co-authored-by: Ethiraric <ethiraric@gmail.com>
Also helps in some cases with #142, when the BOM is at the beginning of
the file (common), but not in corner case where the BOM is at the start
of a document which is not the first one.
Closes: #155
YAML 1.2 has special handling of indicators to be compatible with JSON.
The following is equivalent to `{"a": "b"}` (note, no space after `:`):
{"a":b}
But without the quoted key, a space is required. So the `:` here is part
of the plain scalar:
{a:b} # == {"a:b"}
A plain scalar can also start with a `:` as long as it's followed by
"safe" characters:
{a: :b} # == {"a": ":b"}
(Fixes#118)