From 06747c669f3e6fb53270b76975d4382e52d567e2 Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Thu, 11 Aug 2016 19:28:28 +0800 Subject: [PATCH] Add another test for ! --- src/test/run-pass/impl-for-never.rs | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/run-pass/impl-for-never.rs diff --git a/src/test/run-pass/impl-for-never.rs b/src/test/run-pass/impl-for-never.rs new file mode 100644 index 000000000000..504779ebeb50 --- /dev/null +++ b/src/test/run-pass/impl-for-never.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] + +trait StringifyType { + fn stringify_type() -> &'static str; +} + +impl StringifyType for ! { + fn stringify_type() -> &'static str { + "!" + } +} + +fn maybe_stringify(opt: Option) -> &'static str { + match opt { + Some(_) => T::stringify_type(), + None => "none", + } +} + +fn main() { + println!("! is {}", ::stringify_type()); + println!("None is {}", maybe_stringify(None::)); +} +