(doc1: &Document, doc2: &Document)
| 525 | /// returns Ok() if two Documents are equal or some info where they differ in the Err |
| 526 | #[allow(dead_code)] |
| 527 | fn is_same_doc(doc1: &Document, doc2: &Document) -> Result<()> { |
| 528 | // assume 'e' doesn't have element children until proven otherwise |
| 529 | // this means we keep Text children until we are proven they aren't needed |
| 530 | if doc1.root().children().len() != doc2.root().children().len() { |
| 531 | bail!("Children of docs have {} != {} children", doc1.root().children().len(), doc2.root().children().len()); |
| 532 | } |
| 533 | |
| 534 | for (i, (c1, c2)) in doc1.root().children().iter().zip(doc2.root().children().iter()).enumerate() { |
| 535 | match c1 { |
| 536 | ChildOfRoot::Element(e1) => { |
| 537 | if let ChildOfRoot::Element(e2) = c2 { |
| 538 | is_same_element(e1, e2)?; |
| 539 | } else { |
| 540 | bail!("child #{}, first is element, second is something else", i); |
| 541 | } |
| 542 | }, |
| 543 | ChildOfRoot::Comment(com1) => { |
| 544 | if let ChildOfRoot::Comment(com2) = c2 { |
| 545 | if com1.text() != com2.text() { |
| 546 | bail!("child #{} -- comment text differs", i); |
| 547 | } |
| 548 | } else { |
| 549 | bail!("child #{}, first is comment, second is something else", i); |
| 550 | } |
| 551 | } |
| 552 | ChildOfRoot::ProcessingInstruction(p1) => { |
| 553 | if let ChildOfRoot::ProcessingInstruction(p2) = c2 { |
| 554 | if p1.target() != p2.target() || p1.value() != p2.value() { |
| 555 | bail!("child #{} -- processing instruction differs", i); |
| 556 | } |
| 557 | } else { |
| 558 | bail!("child #{}, first is processing instruction, second is something else", i); |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | }; |
| 563 | return Ok( () ); |
| 564 | } |
| 565 | |
| 566 | /// returns Ok() if two Documents are equal or some info where they differ in the Err |
| 567 | // Not really meant to be public -- used by tests in some packages |
no test coverage detected