From 7140c113b09266747c9add120e27b3e0eb017214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Thu, 18 Jul 2019 18:45:50 +0000 Subject: add more power to add/sub operators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- README.rst | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'README.rst') diff --git a/README.rst b/README.rst index fae2397..208ddbd 100644 --- a/README.rst +++ b/README.rst @@ -157,9 +157,12 @@ Addition :: + inet('192.0.2.0') + 24 -- returns inet('192.0.2.24') inet('2001:db8::/64') + 5 -- returns inet('2001:db8::5/64') - --inet('::ffff:0.0.0.0/96') + inet('192.0.2.24') -- returns inet('192.0.2.24') + -- mixed networks special: + inet('::ffff:0.0.0.0/96') + inet('192.0.2.24') -- returns inet('::ffff:192.0.2.24') + inet('192.0.2.24') + inet('::ffff:0.0.0.0/96') -- returns inet('::ffff:192.0.2.24') ``foo - bar`` ~~~~~~~~~~~~~ @@ -170,7 +173,17 @@ Subtract inet('2001:db8::5/64') - 5 -- returns inet('2001:db8::/64') - --inet('2001:db8::5/64') - inet('2001:db8::') -- returns 5 + inet('192.0.2.24') - inet('192.0.2.0') -- returns 24 + + inet('2001:db8::5/64') - inet('2001:db8::') -- returns 5 + + -- by calling the operator method directly additional debuging info are available: + inet('2001:db8::5/64') - inet('ffff::') -- returns nil + inet('2001:db8::5/64'):__sub(inet('ffff::')) + -- returns nil, 'result is out of range', { 8194, 3512, 0, 0, 0, 0, 0, 5 } + + -- mixed networks special: + inet('::ffff:192.0.2.24') - inet('::ffff:0.0.0.0/96') -- returns inet('192.0.2.24') ``foo / bar`` ~~~~~~~~~~~~~ -- cgit v1.2.1