mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Add default formatters for Au and Range
This commit is contained in:
parent
8010493089
commit
e7e7eab905
2 changed files with 14 additions and 0 deletions
|
@ -7,6 +7,7 @@ use geom::rect::Rect;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
|
|
||||||
use std::num::{NumCast, One, Zero};
|
use std::num::{NumCast, One, Zero};
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
pub struct Au(i32);
|
pub struct Au(i32);
|
||||||
|
|
||||||
|
@ -18,6 +19,12 @@ impl Clone for Au {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Default for Au {
|
||||||
|
fn fmt(obj: &Au, f: &mut fmt::Formatter) {
|
||||||
|
write!(f.buf, "Au({})", *obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Eq for Au {
|
impl Eq for Au {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Au) -> bool {
|
fn eq(&self, other: &Au) -> bool {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
enum RangeRelation {
|
enum RangeRelation {
|
||||||
OverlapsBegin(/* overlap */ uint),
|
OverlapsBegin(/* overlap */ uint),
|
||||||
|
@ -21,6 +22,12 @@ pub struct Range {
|
||||||
priv len: uint
|
priv len: uint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Default for Range {
|
||||||
|
fn fmt(obj: &Range, f: &mut fmt::Formatter) {
|
||||||
|
write!(f.buf, "[{} .. {})", obj.begin(), obj.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Range {
|
impl Range {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(off: uint, len: uint) -> Range {
|
pub fn new(off: uint, len: uint) -> Range {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue