}
#[stable]
-impl<Sized? T: PartialEq> PartialEq for Box<T> {
+impl<T: ?Sized + PartialEq> PartialEq for Box<T> {
#[inline]
fn eq(&self, other: &Box<T>) -> bool { PartialEq::eq(&**self, &**other) }
#[inline]
fn ne(&self, other: &Box<T>) -> bool { PartialEq::ne(&**self, &**other) }
}
#[stable]
-impl<Sized? T: PartialOrd> PartialOrd for Box<T> {
+impl<T: ?Sized + PartialOrd> PartialOrd for Box<T> {
#[inline]
fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> {
PartialOrd::partial_cmp(&**self, &**other)
fn gt(&self, other: &Box<T>) -> bool { PartialOrd::gt(&**self, &**other) }
}
#[stable]
-impl<Sized? T: Ord> Ord for Box<T> {
+impl<T: ?Sized + Ord> Ord for Box<T> {
#[inline]
fn cmp(&self, other: &Box<T>) -> Ordering {
Ord::cmp(&**self, &**other)
}
#[stable]}
-impl<Sized? T: Eq> Eq for Box<T> {}
+impl<T: ?Sized + Eq> Eq for Box<T> {}
-impl<S: hash::Writer, Sized? T: Hash<S>> Hash<S> for Box<T> {
+impl<S: hash::Writer, T: ?Sized + Hash<S>> Hash<S> for Box<T> {
#[inline]
fn hash(&self, state: &mut S) {
(**self).hash(state);
}
}
-impl<Sized? T: fmt::Show> fmt::Show for Box<T> {
+impl<T: ?Sized + fmt::Show> fmt::Show for Box<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f)
}
}
}
-impl<Sized? T> Deref for Box<T> {
+impl<T: ?Sized> Deref for Box<T> {
type Target = T;
fn deref(&self) -> &T { &**self }
}
-impl<Sized? T> DerefMut for Box<T> {
+impl<T: ?Sized> DerefMut for Box<T> {
fn deref_mut(&mut self) -> &mut T { &mut **self }
}
#[stable]
/// A view into a single entry in a map, which may either be vacant or occupied.
-pub enum Entry<'a, Sized? Q:'a, K:'a, V:'a> {
+pub enum Entry<'a, Q: ?Sized +'a, K:'a, V:'a> {
/// A vacant Entry
Vacant(VacantEntry<'a, Q, K, V>),
/// An occupied Entry
#[stable]
/// A vacant Entry.
-pub struct VacantEntry<'a, Sized? Q:'a, K:'a, V:'a> {
+pub struct VacantEntry<'a, Q: ?Sized +'a, K:'a, V:'a> {
key: &'a Q,
stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
}
/// assert_eq!(map.get(&2), None);
/// ```
#[stable]
- pub fn get<Sized? Q>(&self, key: &Q) -> Option<&V> where Q: BorrowFrom<K> + Ord {
+ pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where Q: BorrowFrom<K> + Ord {
let mut cur_node = &self.root;
loop {
match Node::search(cur_node, key) {
/// assert_eq!(map.contains_key(&2), false);
/// ```
#[stable]
- pub fn contains_key<Sized? Q>(&self, key: &Q) -> bool where Q: BorrowFrom<K> + Ord {
+ pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where Q: BorrowFrom<K> + Ord {
self.get(key).is_some()
}
/// ```
// See `get` for implementation notes, this is basically a copy-paste with mut's added
#[stable]
- pub fn get_mut<Sized? Q>(&mut self, key: &Q) -> Option<&mut V> where Q: BorrowFrom<K> + Ord {
+ pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where Q: BorrowFrom<K> + Ord {
// temp_node is a Borrowck hack for having a mutable value outlive a loop iteration
let mut temp_node = &mut self.root;
loop {
/// assert_eq!(map.remove(&1), None);
/// ```
#[stable]
- pub fn remove<Sized? Q>(&mut self, key: &Q) -> Option<V> where Q: BorrowFrom<K> + Ord {
+ pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where Q: BorrowFrom<K> + Ord {
// See `swap` for a more thorough description of the stuff going on in here
let mut stack = stack::PartialSearchStack::new(self);
loop {
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
#[stable]
-impl<K: Ord, Sized? Q, V> Index<Q, V> for BTreeMap<K, V>
+impl<K: Ord, Q: ?Sized, V> Index<Q, V> for BTreeMap<K, V>
where Q: BorrowFrom<K> + Ord
{
fn index(&self, key: &Q) -> &V {
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
#[stable]
-impl<K: Ord, Sized? Q, V> Index<Q> for BTreeMap<K, V>
+impl<K: Ord, Q: ?Sized, V> Index<Q> for BTreeMap<K, V>
where Q: BorrowFrom<K> + Ord
{
type Output = V;
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
#[stable]
-impl<K: Ord, Sized? Q, V> IndexMut<Q, V> for BTreeMap<K, V>
+impl<K: Ord, Q: ?Sized, V> IndexMut<Q, V> for BTreeMap<K, V>
where Q: BorrowFrom<K> + Ord
{
fn index_mut(&mut self, key: &Q) -> &mut V {
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
#[stable]
-impl<K: Ord, Sized? Q, V> IndexMut<Q> for BTreeMap<K, V>
+impl<K: Ord, Q: ?Sized, V> IndexMut<Q> for BTreeMap<K, V>
where Q: BorrowFrom<K> + Ord
{
type Output = V;
#[stable]
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {}
-impl<'a, Sized? Q, K: Ord, V> Entry<'a, Q, K, V> {
+impl<'a, Q: ?Sized, K: Ord, V> Entry<'a, Q, K, V> {
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
}
}
-impl<'a, Sized? Q: ToOwned<K>, K: Ord, V> VacantEntry<'a, Q, K, V> {
+impl<'a, Q: ?Sized + ToOwned<K>, K: Ord, V> VacantEntry<'a, Q, K, V> {
#[stable]
/// Sets the value of the entry with the VacantEntry's key,
/// and returns a mutable reference to it.
/// ```
/// The key must have the same ordering before or after `.to_owned()` is called.
#[stable]
- pub fn entry<'a, Sized? Q>(&'a mut self, mut key: &'a Q) -> Entry<'a, Q, K, V>
+ pub fn entry<'a, Q: ?Sized>(&'a mut self, mut key: &'a Q) -> Entry<'a, Q, K, V>
where Q: Ord + ToOwned<K>
{
// same basic logic of `swap` and `pop`, blended together
/// Searches for the given key in the node. If it finds an exact match,
/// `Found` will be yielded with the matching index. If it doesn't find an exact match,
/// `GoDown` will be yielded with the index of the subtree the key must lie in.
- pub fn search<Sized? Q, NodeRef: Deref<Target=Node<K, V>>>(node: NodeRef, key: &Q)
+ pub fn search<Q: ?Sized, NodeRef: Deref<Target=Node<K, V>>>(node: NodeRef, key: &Q)
-> SearchResult<NodeRef> where Q: BorrowFrom<K> + Ord {
// FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V).
// For the B configured as of this writing (B = 6), binary search was *significantly*
}
}
- fn search_linear<Sized? Q>(&self, key: &Q) -> (bool, uint) where Q: BorrowFrom<K> + Ord {
+ fn search_linear<Q: ?Sized>(&self, key: &Q) -> (bool, uint) where Q: BorrowFrom<K> + Ord {
for (i, k) in self.keys().iter().enumerate() {
match key.cmp(BorrowFrom::borrow_from(k)) {
Greater => {},
/// assert_eq!(set.contains(&4), false);
/// ```
#[stable]
- pub fn contains<Sized? Q>(&self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
+ pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
self.map.contains_key(value)
}
/// assert_eq!(set.remove(&2), false);
/// ```
#[stable]
- pub fn remove<Sized? Q>(&mut self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
+ pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
self.map.remove(value).is_some()
}
}
////////////////////////////////////////////////////////////////////////////////
#[unstable = "U should be an associated type"]
/// An extension trait for concatenating slices
-pub trait SliceConcatExt<Sized? T, U> for Sized? {
+pub trait SliceConcatExt<T: ?Sized, U> for Sized? {
/// Flattens a slice of `T` into a single value `U`.
#[stable]
fn concat(&self) -> U;
use self::Cow::*;
/// A trait for borrowing data.
-pub trait BorrowFrom<Sized? Owned> for Sized? {
+pub trait BorrowFrom<Owned: ?Sized> for Sized? {
/// Immutably borrow from an owned value.
fn borrow_from(owned: &Owned) -> &Self;
}
/// A trait for mutably borrowing data.
-pub trait BorrowFromMut<Sized? Owned> for Sized? : BorrowFrom<Owned> {
+pub trait BorrowFromMut<Owned: ?Sized> for Sized? : BorrowFrom<Owned> {
/// Mutably borrow from an owned value.
fn borrow_from_mut(owned: &mut Owned) -> &mut Self;
}
-impl<Sized? T> BorrowFrom<T> for T {
+impl<T: ?Sized> BorrowFrom<T> for T {
fn borrow_from(owned: &T) -> &T { owned }
}
-impl<Sized? T> BorrowFromMut<T> for T {
+impl<T: ?Sized> BorrowFromMut<T> for T {
fn borrow_from_mut(owned: &mut T) -> &mut T { owned }
}
-impl<'a, Sized? T> BorrowFrom<&'a T> for T {
+impl<'a, T: ?Sized> BorrowFrom<&'a T> for T {
fn borrow_from<'b>(owned: &'b &'a T) -> &'b T { &**owned }
}
-impl<'a, Sized? T> BorrowFrom<&'a mut T> for T {
+impl<'a, T: ?Sized> BorrowFrom<&'a mut T> for T {
fn borrow_from<'b>(owned: &'b &'a mut T) -> &'b T { &**owned }
}
-impl<'a, Sized? T> BorrowFromMut<&'a mut T> for T {
+impl<'a, T: ?Sized> BorrowFromMut<&'a mut T> for T {
fn borrow_from_mut<'b>(owned: &'b mut &'a mut T) -> &'b mut T { &mut **owned }
}
-impl<'a, T, Sized? B> BorrowFrom<Cow<'a, T, B>> for B where B: ToOwned<T> {
+impl<'a, T, B: ?Sized> BorrowFrom<Cow<'a, T, B>> for B where B: ToOwned<T> {
fn borrow_from<'b>(owned: &'b Cow<'a, T, B>) -> &'b B {
&**owned
}
}
/// Trait for moving into a `Cow`
-pub trait IntoCow<'a, T, Sized? B> {
+pub trait IntoCow<'a, T, B: ?Sized> {
/// Moves `self` into `Cow`
fn into_cow(self) -> Cow<'a, T, B>;
}
-impl<'a, T, Sized? B> IntoCow<'a, T, B> for Cow<'a, T, B> where B: ToOwned<T> {
+impl<'a, T, B: ?Sized> IntoCow<'a, T, B> for Cow<'a, T, B> where B: ToOwned<T> {
fn into_cow(self) -> Cow<'a, T, B> {
self
}
/// }
/// }
/// ```
-pub enum Cow<'a, T, Sized? B: 'a> where B: ToOwned<T> {
+pub enum Cow<'a, T, B: ?Sized + 'a> where B: ToOwned<T> {
/// Borrowed data.
Borrowed(&'a B),
}
#[stable]
-impl<'a, T, Sized? B> Clone for Cow<'a, T, B> where B: ToOwned<T> {
+impl<'a, T, B: ?Sized> Clone for Cow<'a, T, B> where B: ToOwned<T> {
fn clone(&self) -> Cow<'a, T, B> {
match *self {
Borrowed(b) => Borrowed(b),
}
}
-impl<'a, T, Sized? B> Cow<'a, T, B> where B: ToOwned<T> {
+impl<'a, T, B: ?Sized> Cow<'a, T, B> where B: ToOwned<T> {
/// Acquire a mutable reference to the owned form of the data.
///
/// Copies the data if it is not already owned.
}
}
-impl<'a, T, Sized? B> Deref for Cow<'a, T, B> where B: ToOwned<T> {
+impl<'a, T, B: ?Sized> Deref for Cow<'a, T, B> where B: ToOwned<T> {
type Target = B;
fn deref(&self) -> &B {
}
#[stable]
-impl<'a, T, Sized? B> Eq for Cow<'a, T, B> where B: Eq + ToOwned<T> {}
+impl<'a, T, B: ?Sized> Eq for Cow<'a, T, B> where B: Eq + ToOwned<T> {}
#[stable]
-impl<'a, T, Sized? B> Ord for Cow<'a, T, B> where B: Ord + ToOwned<T> {
+impl<'a, T, B: ?Sized> Ord for Cow<'a, T, B> where B: Ord + ToOwned<T> {
#[inline]
fn cmp(&self, other: &Cow<'a, T, B>) -> Ordering {
Ord::cmp(&**self, &**other)
}
#[stable]
-impl<'a, 'b, T, U, Sized? B, Sized? C> PartialEq<Cow<'b, U, C>> for Cow<'a, T, B> where
+impl<'a, 'b, T, U, B: ?Sized, C: ?Sized> PartialEq<Cow<'b, U, C>> for Cow<'a, T, B> where
B: PartialEq<C> + ToOwned<T>,
C: ToOwned<U>,
{
}
#[stable]
-impl<'a, T, Sized? B> PartialOrd for Cow<'a, T, B> where B: PartialOrd + ToOwned<T> {
+impl<'a, T, B: ?Sized> PartialOrd for Cow<'a, T, B> where B: PartialOrd + ToOwned<T> {
#[inline]
fn partial_cmp(&self, other: &Cow<'a, T, B>) -> Option<Ordering> {
PartialOrd::partial_cmp(&**self, &**other)
}
}
-impl<'a, T, Sized? B> fmt::Show for Cow<'a, T, B> where B: fmt::Show + ToOwned<T>, T: fmt::Show {
+impl<'a, T, B: ?Sized> fmt::Show for Cow<'a, T, B> where B: fmt::Show + ToOwned<T>, T: fmt::Show {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Borrowed(ref b) => fmt::Show::fmt(b, f),
}
#[stable]
-impl<'a, Sized? T> Clone for &'a T {
+impl<'a, T: ?Sized> Clone for &'a T {
/// Return a shallow copy of the reference.
#[inline]
fn clone(&self) -> &'a T { *self }
/// only if `a != b`.
#[lang="eq"]
#[stable]
-pub trait PartialEq<Sized? Rhs = Self> for Sized? {
+pub trait PartialEq<Rhs: ?Sized = Self> for Sized? {
/// This method tests for `self` and `other` values to be equal, and is used by `==`.
#[stable]
fn eq(&self, other: &Rhs) -> bool;
/// 5.11).
#[lang="ord"]
#[stable]
-pub trait PartialOrd<Sized? Rhs = Self> for Sized?: PartialEq<Rhs> {
+pub trait PartialOrd<Rhs: ?Sized = Self> for Sized?: PartialEq<Rhs> {
/// This method returns an ordering between `self` and `other` values
/// if one exists.
#[stable]
// & pointers
#[stable]
- impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b B> for &'a A where A: PartialEq<B> {
+ impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a A where A: PartialEq<B> {
#[inline]
fn eq(&self, other: & &'b B) -> bool { PartialEq::eq(*self, *other) }
#[inline]
fn ne(&self, other: & &'b B) -> bool { PartialEq::ne(*self, *other) }
}
#[stable]
- impl<'a, 'b, Sized? A, Sized? B> PartialOrd<&'b B> for &'a A where A: PartialOrd<B> {
+ impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b B> for &'a A where A: PartialOrd<B> {
#[inline]
fn partial_cmp(&self, other: &&'b B) -> Option<Ordering> {
PartialOrd::partial_cmp(*self, *other)
fn gt(&self, other: & &'b B) -> bool { PartialOrd::gt(*self, *other) }
}
#[stable]
- impl<'a, Sized? A> Ord for &'a A where A: Ord {
+ impl<'a, A: ?Sized> Ord for &'a A where A: Ord {
#[inline]
fn cmp(&self, other: & &'a A) -> Ordering { Ord::cmp(*self, *other) }
}
#[stable]
- impl<'a, Sized? A> Eq for &'a A where A: Eq {}
+ impl<'a, A: ?Sized> Eq for &'a A where A: Eq {}
// &mut pointers
#[stable]
- impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+ impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
#[inline]
fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
#[inline]
fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
}
#[stable]
- impl<'a, 'b, Sized? A, Sized? B> PartialOrd<&'b mut B> for &'a mut A where A: PartialOrd<B> {
+ impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b mut B> for &'a mut A where A: PartialOrd<B> {
#[inline]
fn partial_cmp(&self, other: &&'b mut B) -> Option<Ordering> {
PartialOrd::partial_cmp(*self, *other)
fn gt(&self, other: &&'b mut B) -> bool { PartialOrd::gt(*self, *other) }
}
#[stable]
- impl<'a, Sized? A> Ord for &'a mut A where A: Ord {
+ impl<'a, A: ?Sized> Ord for &'a mut A where A: Ord {
#[inline]
fn cmp(&self, other: &&'a mut A) -> Ordering { Ord::cmp(*self, *other) }
}
#[stable]
- impl<'a, Sized? A> Eq for &'a mut A where A: Eq {}
+ impl<'a, A: ?Sized> Eq for &'a mut A where A: Eq {}
#[stable]
- impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b mut B> for &'a A where A: PartialEq<B> {
+ impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a A where A: PartialEq<B> {
#[inline]
fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
#[inline]
}
#[stable]
- impl<'a, 'b, Sized? A, Sized? B> PartialEq<&'b B> for &'a mut A where A: PartialEq<B> {
+ impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a mut A where A: PartialEq<B> {
#[inline]
fn eq(&self, other: &&'b B) -> bool { PartialEq::eq(*self, *other) }
#[inline]
// This Adapter is needed to allow `self` (of type `&mut
// Self`) to be cast to a FormatWriter (below) without
// requiring a `Sized` bound.
- struct Adapter<'a,Sized? T:'a>(&'a mut T);
+ struct Adapter<'a,T: ?Sized +'a>(&'a mut T);
- impl<'a, Sized? T> Writer for Adapter<'a, T>
+ impl<'a, T: ?Sized> Writer for Adapter<'a, T>
where T: Writer
{
fn write_str(&mut self, s: &str) -> Result {
// Implementations of the core formatting traits
-impl<'a, Sized? T: Show> Show for &'a T {
+impl<'a, T: ?Sized + Show> Show for &'a T {
fn fmt(&self, f: &mut Formatter) -> Result { (**self).fmt(f) }
}
-impl<'a, Sized? T: Show> Show for &'a mut T {
+impl<'a, T: ?Sized + Show> Show for &'a mut T {
fn fmt(&self, f: &mut Formatter) -> Result { (**self).fmt(f) }
}
/// containers like `HashMap`, which need a generic way hash multiple types.
pub trait Hasher<S> {
/// Compute the hash of a value.
- fn hash<Sized? T: Hash<S>>(&self, value: &T) -> u64;
+ fn hash<T: ?Sized + Hash<S>>(&self, value: &T) -> u64;
}
#[allow(missing_docs)]
}
-impl<'a, S: Writer, Sized? T: Hash<S>> Hash<S> for &'a T {
+impl<'a, S: Writer, T: ?Sized + Hash<S>> Hash<S> for &'a T {
#[inline]
fn hash(&self, state: &mut S) {
(**self).hash(state);
}
}
-impl<'a, S: Writer, Sized? T: Hash<S>> Hash<S> for &'a mut T {
+impl<'a, S: Writer, T: ?Sized + Hash<S>> Hash<S> for &'a mut T {
#[inline]
fn hash(&self, state: &mut S) {
(**self).hash(state);
}
}
-impl<'a, T, Sized? B, S> Hash<S> for Cow<'a, T, B> where B: Hash<S> + ToOwned<T> {
+impl<'a, T, B: ?Sized, S> Hash<S> for Cow<'a, T, B> where B: Hash<S> + ToOwned<T> {
#[inline]
fn hash(&self, state: &mut S) {
Hash::hash(&**self, state)
impl Hasher<SipState> for SipHasher {
#[inline]
- fn hash<Sized? T: Hash<SipState>>(&self, value: &T) -> u64 {
+ fn hash<T: ?Sized + Hash<SipState>>(&self, value: &T) -> u64 {
let mut state = SipState::new_with_keys(self.k0, self.k1);
value.hash(&mut state);
state.result()
/// Hashes a value using the SipHash algorithm.
#[inline]
-pub fn hash<Sized? T: Hash<SipState>>(value: &T) -> u64 {
+pub fn hash<T: ?Sized + Hash<SipState>>(value: &T) -> u64 {
let mut state = SipState::new();
value.hash(&mut state);
state.result()
/// Hashes a value with the SipHash algorithm with the provided keys.
#[inline]
-pub fn hash_with_keys<Sized? T: Hash<SipState>>(k0: u64, k1: u64, value: &T) -> u64 {
+pub fn hash_with_keys<T: ?Sized + Hash<SipState>>(k0: u64, k1: u64, value: &T) -> u64 {
let mut state = SipState::new_with_keys(k0, k1);
value.hash(&mut state);
state.result()
/// for some lifetime `'a`, but not the other way around).
#[lang="covariant_type"]
#[derive(PartialEq, Eq, PartialOrd, Ord)]
- pub struct CovariantType<Sized? T>;
+ pub struct CovariantType<T: ?Sized>;
- impl<Sized? T> Copy for CovariantType<T> {}
- impl<Sized? T> Clone for CovariantType<T> {
+ impl<T: ?Sized> Copy for CovariantType<T> {}
+ impl<T: ?Sized> Clone for CovariantType<T> {
fn clone(&self) -> CovariantType<T> { *self }
}
/// arguments of type `U`, hence such a conversion is safe.
#[lang="contravariant_type"]
#[derive(PartialEq, Eq, PartialOrd, Ord)]
- pub struct ContravariantType<Sized? T>;
+ pub struct ContravariantType<T: ?Sized>;
- impl<Sized? T> Copy for ContravariantType<T> {}
- impl<Sized? T> Clone for ContravariantType<T> {
+ impl<T: ?Sized> Copy for ContravariantType<T> {}
+ impl<T: ?Sized> Clone for ContravariantType<T> {
fn clone(&self) -> ContravariantType<T> { *self }
}
/// interior mutability.
#[lang="invariant_type"]
#[derive(PartialEq, Eq, PartialOrd, Ord)]
- pub struct InvariantType<Sized? T>;
+ pub struct InvariantType<T: ?Sized>;
- impl<Sized? T> Copy for InvariantType<T> {}
- impl<Sized? T> Clone for InvariantType<T> {
+ impl<T: ?Sized> Copy for InvariantType<T> {}
+ impl<T: ?Sized> Clone for InvariantType<T> {
fn clone(&self) -> InvariantType<T> { *self }
}
#[inline]
#[unstable = "this function may be removed in the future due to its \
questionable utility"]
-pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S,
+pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
ptr: &T) -> &'a T {
transmute(ptr)
}
#[inline]
#[unstable = "this function may be removed in the future due to its \
questionable utility"]
-pub unsafe fn copy_mut_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a mut S,
+pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a mut S,
ptr: &mut T)
-> &'a mut T {
transmute(ptr)
#[cfg(stage0)]
#[allow(missing_docs)]
#[lang="index"]
-pub trait Index<Sized? Index, Sized? Result> for Sized? {
+pub trait Index<Index: ?Sized, Result: ?Sized> for Sized? {
/// The method for the indexing (`Foo[Bar]`) operation
fn index<'a>(&'a self, index: &Index) -> &'a Result;
}
/// ```
#[cfg(not(stage0))] // NOTE(stage0) remove cfg after a snapshot
#[lang="index"]
-pub trait Index<Sized? Index> for Sized? {
- type Sized? Output;
+pub trait Index<Index: ?Sized> for Sized? {
+ type Output: ?Sized;
/// The method for the indexing (`Foo[Bar]`) operation
fn index<'a>(&'a self, index: &Index) -> &'a Self::Output;
#[cfg(stage0)]
#[allow(missing_docs)]
#[lang="index_mut"]
-pub trait IndexMut<Sized? Index, Sized? Result> for Sized? {
+pub trait IndexMut<Index: ?Sized, Result: ?Sized> for Sized? {
/// The method for the indexing (`Foo[Bar]`) operation
fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result;
}
/// ```
#[cfg(not(stage0))] // NOTE(stage0) remove cfg after a snapshot
#[lang="index_mut"]
-pub trait IndexMut<Sized? Index> for Sized? {
- type Sized? Output;
+pub trait IndexMut<Index: ?Sized> for Sized? {
+ type Output: ?Sized;
/// The method for the indexing (`Foo[Bar]`) operation
fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Self::Output;
/// }
/// ```
#[lang="slice"]
-pub trait Slice<Sized? Idx, Sized? Result> for Sized? {
+pub trait Slice<Idx: ?Sized, Result: ?Sized> for Sized? {
/// The method for the slicing operation foo[]
fn as_slice_<'a>(&'a self) -> &'a Result;
/// The method for the slicing operation foo[from..]
/// }
/// ```
#[lang="slice_mut"]
-pub trait SliceMut<Sized? Idx, Sized? Result> for Sized? {
+pub trait SliceMut<Idx: ?Sized, Result: ?Sized> for Sized? {
/// The method for the slicing operation foo[]
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
/// The method for the slicing operation foo[from..]
/// ```
#[lang="deref"]
pub trait Deref for Sized? {
- type Sized? Target;
+ type Target: ?Sized;
/// The method called to dereference a value
fn deref<'a>(&'a self) -> &'a Self::Target;
}
-impl<'a, Sized? T> Deref for &'a T {
+impl<'a, T: ?Sized> Deref for &'a T {
type Target = T;
fn deref(&self) -> &T { *self }
}
-impl<'a, Sized? T> Deref for &'a mut T {
+impl<'a, T: ?Sized> Deref for &'a mut T {
type Target = T;
fn deref(&self) -> &T { *self }
fn deref_mut<'a>(&'a mut self) -> &'a mut <Self as Deref>::Target;
}
-impl<'a, Sized? T> DerefMut for &'a mut T {
+impl<'a, T: ?Sized> DerefMut for &'a mut T {
fn deref_mut(&mut self) -> &mut T { *self }
}
extern "rust-call" fn call_once(self, args: Args) -> Result;
}
-impl<Sized? F,A,R> FnMut<A,R> for F
- where F : Fn<A,R>
+impl<F: ?Sized, A, R> FnMut<A, R> for F
+ where F : Fn<A, R>
{
extern "rust-call" fn call_mut(&mut self, args: A) -> R {
self.call(args)
}
#[experimental = "trait is experimental"]
-impl<'a, T, Sized? U: AsSlice<T>> AsSlice<T> for &'a U {
+impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a U {
#[inline(always)]
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
}
#[experimental = "trait is experimental"]
-impl<'a, T, Sized? U: AsSlice<T>> AsSlice<T> for &'a mut U {
+impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a mut U {
#[inline(always)]
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
}
fn as_slice<'a>(&'a self) -> &'a str { self }
}
-impl<'a, Sized? S> Str for &'a S where S: Str {
+impl<'a, S: ?Sized> Str for &'a S where S: Str {
#[inline]
fn as_slice(&self) -> &str { Str::as_slice(*self) }
}
struct MyWriterHasher;
impl Hasher<MyWriter> for MyWriterHasher {
- fn hash<Sized? T: Hash<MyWriter>>(&self, value: &T) -> u64 {
+ fn hash<T: ?Sized + Hash<MyWriter>>(&self, value: &T) -> u64 {
let mut state = MyWriter { hash: 0 };
value.hash(&mut state);
state.hash
// Note 2: Once Dynamically Sized Types (DST) lands, it might be
// reasonable to replace this with something like `enum MaybeOwned<'a,
-// Sized? U>{ Owned(Box<U>), Borrowed(&'a U) }`; and then `U` could be
+// U: ?Sized>{ Owned(Box<U>), Borrowed(&'a U) }`; and then `U` could be
// instantiated with `[T]` or `str`, etc. Of course, that would imply
// removing the `Growable` variant, which relates to note 1 above.
// Alternatively, we might add `MaybeOwned` for the general case but
// However, it's not as simple as checking whether `T :
// Sized`, because even if `T : Sized` does not hold, that
// just means that `T` *may* not be sized. After all, even a
- // type parameter `Sized? T` could be bound to a sized
+ // type parameter `T: ?Sized` could be bound to a sized
// type. (Issue #20116)
//
// To handle this, we first check for "interior" type
// exhaustively checking all possible combinations. Here are some examples:
//
// ```
- // fn foo<T,U>() {
+ // fn foo<T, U>() {
// // T=int, U=int
// }
//
- // fn bar<Sized? T,U>() {
+ // fn bar<T: ?Sized, U>() {
// // T=int, U=int
// // T=[int], U=int
// }
//
- // fn baz<Sized? T, Sized?U>() {
+ // fn baz<T: ?Sized, U: ?Sized>() {
// // T=int, U=int
// // T=[int], U=int
// // T=int, U=[int]
pub struct FnvState(u64);
impl Hasher<FnvState> for FnvHasher {
- fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 {
+ fn hash<T: ?Sized + Hash<FnvState>>(&self, t: &T) -> u64 {
let mut state = FnvState(0xcbf29ce484222325);
t.hash(&mut state);
let FnvState(ret) = state;
}
}
-impl<'a, 'tcx, Sized? T:Repr<'tcx>> Repr<'tcx> for &'a T {
+impl<'a, 'tcx, T: ?Sized +Repr<'tcx>> Repr<'tcx> for &'a T {
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
Repr::repr(*self, tcx)
}
}
}
-impl<'a, Sized? T: Encodable> Encodable for &'a T {
+impl<'a, T: ?Sized + Encodable> Encodable for &'a T {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
(**self).encode(s)
}
}
-impl<Sized? T: Encodable> Encodable for Box<T> {
+impl<T: ?Sized + Encodable> Encodable for Box<T> {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
(**self).encode(s)
}
}
}
-impl<'a, E, S: Encoder<E>, Sized? T: Encodable<S, E>> Encodable<S, E> for &'a T {
+impl<'a, E, S: Encoder<E>, T: ?Sized + Encodable<S, E>> Encodable<S, E> for &'a T {
fn encode(&self, s: &mut S) -> Result<(), E> {
(**self).encode(s)
}
}
-impl<E, S: Encoder<E>, Sized? T: Encodable<S, E>> Encodable<S, E> for Box<T> {
+impl<E, S: Encoder<E>, T: ?Sized + Encodable<S, E>> Encodable<S, E> for Box<T> {
fn encode(&self, s: &mut S) -> Result<(), E> {
(**self).encode(s)
}
}
}
-impl<'a, Sized? T: ToCStr> ToCStr for &'a T {
+impl<'a, T: ?Sized + ToCStr> ToCStr for &'a T {
#[inline]
fn to_c_str(&self) -> CString {
(**self).to_c_str()
}
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
- fn make_hash<Sized? X: Hash<S>>(&self, x: &X) -> SafeHash {
+ fn make_hash<X: ?Sized + Hash<S>>(&self, x: &X) -> SafeHash {
table::make_hash(&self.hasher, x)
}
/// Search for a key, yielding the index if it's found in the hashtable.
/// If you already have the hash for the key lying around, use
/// search_hashed.
- fn search<'a, Sized? Q>(&'a self, q: &Q) -> Option<FullBucketImm<'a, K, V>>
+ fn search<'a, Q: ?Sized>(&'a self, q: &Q) -> Option<FullBucketImm<'a, K, V>>
where Q: BorrowFrom<K> + Eq + Hash<S>
{
let hash = self.make_hash(q);
.into_option()
}
- fn search_mut<'a, Sized? Q>(&'a mut self, q: &Q) -> Option<FullBucketMut<'a, K, V>>
+ fn search_mut<'a, Q: ?Sized>(&'a mut self, q: &Q) -> Option<FullBucketMut<'a, K, V>>
where Q: BorrowFrom<K> + Eq + Hash<S>
{
let hash = self.make_hash(q);
#[stable]
/// Gets the given key's corresponding entry in the map for in-place manipulation.
/// Regardless of whether or not `to_owned()` has been called, the key must hash the same way.
- pub fn entry<'a, Sized? Q>(&'a mut self, key: &'a Q) -> Entry<'a, Q, K, V>
+ pub fn entry<'a, Q: ?Sized>(&'a mut self, key: &'a Q) -> Entry<'a, Q, K, V>
where Q: Eq + Hash<S> + ToOwned<K>
{
// Gotta resize now.
/// assert_eq!(map.get(&2), None);
/// ```
#[stable]
- pub fn get<Sized? Q>(&self, k: &Q) -> Option<&V>
+ pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
where Q: Hash<S> + Eq + BorrowFrom<K>
{
self.search(k).map(|bucket| bucket.into_refs().1)
/// assert_eq!(map.contains_key(&2), false);
/// ```
#[stable]
- pub fn contains_key<Sized? Q>(&self, k: &Q) -> bool
+ pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
where Q: Hash<S> + Eq + BorrowFrom<K>
{
self.search(k).is_some()
/// assert_eq!(map[1], "b");
/// ```
#[stable]
- pub fn get_mut<Sized? Q>(&mut self, k: &Q) -> Option<&mut V>
+ pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
where Q: Hash<S> + Eq + BorrowFrom<K>
{
self.search_mut(k).map(|bucket| bucket.into_mut_refs().1)
/// assert_eq!(map.remove(&1), None);
/// ```
#[stable]
- pub fn remove<Sized? Q>(&mut self, k: &Q) -> Option<V>
+ pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
where Q: Hash<S> + Eq + BorrowFrom<K>
{
if self.table.size() == 0 {
}
}
-fn search_entry_hashed<'a, K, V, Sized? Q>(table: &'a mut RawTable<K,V>, hash: SafeHash, k: &'a Q)
+fn search_entry_hashed<'a, K, V, Q: ?Sized>(table: &'a mut RawTable<K,V>, hash: SafeHash, k: &'a Q)
-> Entry<'a, Q, K, V>
where Q: Eq + ToOwned<K>
{
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
#[stable]
-impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> Index<Q, V> for HashMap<K, V, H>
+impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> Index<Q, V> for HashMap<K, V, H>
where Q: BorrowFrom<K> + Hash<S> + Eq
{
#[inline]
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
#[stable]
-impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> Index<Q> for HashMap<K, V, H>
+impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> Index<Q> for HashMap<K, V, H>
where Q: BorrowFrom<K> + Hash<S> + Eq
{
type Output = V;
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
#[stable]
-impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> IndexMut<Q, V> for HashMap<K, V, H>
+impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> IndexMut<Q, V> for HashMap<K, V, H>
where Q: BorrowFrom<K> + Hash<S> + Eq
{
#[inline]
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
#[stable]
-impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> IndexMut<Q> for HashMap<K, V, H>
+impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> IndexMut<Q> for HashMap<K, V, H>
where Q: BorrowFrom<K> + Hash<S> + Eq
{
type Output = V;
#[stable]
/// A view into a single empty location in a HashMap
-pub struct VacantEntry<'a, Sized? Q: 'a, K: 'a, V: 'a> {
+pub struct VacantEntry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> {
hash: SafeHash,
key: &'a Q,
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
#[stable]
/// A view into a single location in a map, which may be vacant or occupied
-pub enum Entry<'a, Sized? Q: 'a, K: 'a, V: 'a> {
+pub enum Entry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> {
/// An occupied Entry
Occupied(OccupiedEntry<'a, K, V>),
/// A vacant Entry
}
}
-impl<'a, Sized? Q, K, V> Entry<'a, Q, K, V> {
+impl<'a, Q: ?Sized, K, V> Entry<'a, Q, K, V> {
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
}
}
-impl<'a, Sized? Q: 'a + ToOwned<K>, K: 'a, V: 'a> VacantEntry<'a, Q, K, V> {
+impl<'a, Q: ?Sized + 'a + ToOwned<K>, K: 'a, V: 'a> VacantEntry<'a, Q, K, V> {
#[stable]
/// Sets the value of the entry with the VacantEntry's key,
/// and returns a mutable reference to it
/// assert_eq!(set.contains(&4), false);
/// ```
#[stable]
- pub fn contains<Sized? Q>(&self, value: &Q) -> bool
+ pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
where Q: BorrowFrom<T> + Hash<S> + Eq
{
self.map.contains_key(value)
/// assert_eq!(set.remove(&2), false);
/// ```
#[stable]
- pub fn remove<Sized? Q>(&mut self, value: &Q) -> bool
+ pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
where Q: BorrowFrom<T> + Hash<S> + Eq
{
self.map.remove(value).is_some()
/// We need to remove hashes of 0. That's reserved for empty buckets.
/// This function wraps up `hash_keyed` to be the only way outside this
/// module to generate a SafeHash.
-pub fn make_hash<Sized? T: Hash<S>, S, H: Hasher<S>>(hasher: &H, t: &T) -> SafeHash {
+pub fn make_hash<T: ?Sized + Hash<S>, S, H: Hasher<S>>(hasher: &H, t: &T) -> SafeHash {
// We need to avoid 0u64 in order to prevent collisions with
// EMPTY_HASH. We can maintain our precious uniform distribution
// of initial indexes by unconditionally setting the MSB,
impl Hasher<sip::SipState> for RandomSipHasher {
#[inline]
- fn hash<Sized? T: Hash<sip::SipState>>(&self, value: &T) -> u64 {
+ fn hash<T: ?Sized + Hash<sip::SipState>>(&self, value: &T) -> u64 {
self.hasher.hash(value)
}
}
fn write_fmt(&mut self, fmt: fmt::Arguments) -> IoResult<()> {
// Create a shim which translates a Writer to a fmt::Writer and saves
// off I/O errors. instead of discarding them
- struct Adaptor<'a, Sized? T:'a> {
+ struct Adaptor<'a, T: ?Sized +'a> {
inner: &'a mut T,
error: IoResult<()>,
}
- impl<'a, Sized? T: Writer> fmt::Writer for Adaptor<'a, T> {
+ impl<'a, T: ?Sized + Writer> fmt::Writer for Adaptor<'a, T> {
fn write_str(&mut self, s: &str) -> fmt::Result {
match self.inner.write(s.as_bytes()) {
Ok(()) => Ok(()),
/// `Some`. The `Some` contains the `IoResult` representing whether the
/// connection attempt was successful. A successful connection will be wrapped
/// in `Ok`. A failed connection is represented as an `Err`.
-pub struct IncomingConnections<'a, Sized? A:'a> {
+pub struct IncomingConnections<'a, A: ?Sized +'a> {
inc: &'a mut A,
}
-impl<'a, T, Sized? A: Acceptor<T>> Iterator for IncomingConnections<'a, A> {
+impl<'a, T, A: ?Sized + Acceptor<T>> Iterator for IncomingConnections<'a, A> {
type Item = IoResult<T>;
fn next(&mut self) -> Option<IoResult<T>> {
}
}
-impl<'a, Sized? T: BytesContainer> BytesContainer for &'a T {
+impl<'a, T: ?Sized + BytesContainer> BytesContainer for &'a T {
#[inline]
fn container_as_bytes(&self) -> &[u8] {
(**self).container_as_bytes()
/// Returns a normalized byte vector representation of a path, by removing all empty
/// components, and unnecessary . and .. components.
- fn normalize<Sized? V: AsSlice<u8>>(v: &V) -> Vec<u8> {
+ fn normalize<V: ?Sized + AsSlice<u8>>(v: &V) -> Vec<u8> {
// borrowck is being very picky
let val = {
let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE;
"write `extern crate bar as foo` instead"
),
ObsoleteSyntax::Sized => (
- "`Sized? T` syntax for removing the `Sized` bound",
+ "`T: ?Sized` syntax for removing the `Sized` bound",
"write `T: ?Sized` instead"
),
};
(*vect).len()
}
- pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+ pub fn find<Q: ?Sized>(&self, val: &Q) -> Option<Name>
where Q: BorrowFrom<T> + Eq + Hash {
let map = self.map.borrow();
match (*map).get(val) {
self.vect.borrow().len()
}
- pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+ pub fn find<Q: ?Sized>(&self, val: &Q) -> Option<Name>
where Q: BorrowFrom<RcStr> + Eq + Hash {
match (*self.map.borrow()).get(val) {
Some(v) => Some(*v),
#![feature(associated_types)]
trait Get {
- type Sized? Value;
+ type Value: ?Sized;
fn get(&self) -> <Self as Get>::Value;
}
// Forbid assignment into a dynamically sized type.
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
f1: int,
f2: &'static str,
ptr: T
// Forbid assignment into a dynamically sized type.
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
f1: int,
f2: &'static str,
ptr: T
// Attempt to change the type as well as unsizing.
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
ptr: T
}
// Attempt to change the mutability as well as unsizing.
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
ptr: T
}
// Attempt to extend the lifetime as well as unsizing.
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
ptr: T
}
// Attempt to coerce from unsized to sized.
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
ptr: T
}
trait T {}
impl T for S {}
-struct Foo<Sized? T> {
+struct Foo<T: ?Sized> {
f: T
}
// because it would require stack allocation of an unsized temporary (*g in the
// test).
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
ptr: T
}
trait Foo for Sized? {}
impl Foo for str {}
-fn test1<Sized? T: Foo>(t: &T) {
+fn test1<T: ?Sized + Foo>(t: &T) {
let u: &Foo = t;
//~^ ERROR `core::kinds::Sized` is not implemented for the type `T`
}
-fn test2<Sized? T: Foo>(t: &T) {
+fn test2<T: ?Sized + Foo>(t: &T) {
let v: &Foo = t as &Foo;
//~^ ERROR `core::kinds::Sized` is not implemented for the type `T`
}
use std::mem::transmute;
-fn a<T, Sized? U>(x: &[T]) -> &U {
+fn a<T, U: ?Sized>(x: &[T]) -> &U {
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
}
-fn b<Sized? T, Sized? U>(x: &T) -> &U {
+fn b<T: ?Sized, U: ?Sized>(x: &T) -> &U {
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
}
unsafe { transmute(x) }
}
-fn e<Sized? T, U>(x: &T) -> &U {
+fn e<T: ?Sized, U>(x: &T) -> &U {
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
}
-fn f<T, Sized? U>(x: &T) -> &U {
+fn f<T, U: ?Sized>(x: &T) -> &U {
unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes
}
use std::mem::transmute;
-struct Foo<Sized? T> {
+struct Foo<T: ?Sized> {
t: Box<T>
}
-impl<Sized? T> Foo<T> {
+impl<T: ?Sized> Foo<T> {
fn m(x: &T) -> &int where T : Sized {
// OK here, because T : Sized is in scope.
unsafe { transmute(x) }
fn dummy(&self, t: T, u: U, v: V);
}
-trait Eq<Sized? X> for Sized? { }
-impl<Sized? X> Eq<X> for X { }
-fn eq<Sized? A,Sized? B>() where A : Eq<B> { }
+trait Eq<X: ?Sized> for Sized? { }
+impl<X: ?Sized> Eq<X> for X { }
+fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { }
fn test<'a,'b>() {
// Parens are equivalent to omitting default in angle.
fn dummy(&self, t: T, u: U);
}
-trait Eq<Sized? X> for Sized? { }
-impl<Sized? X> Eq<X> for X { }
-fn eq<Sized? A,Sized? B:Eq<A>>() { }
+trait Eq<X: ?Sized> for Sized? { }
+impl<X: ?Sized> Eq<X> for X { }
+fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
fn test<'a,'b>() {
// No errors expected:
fn dummy(&self, t: T, u: U);
}
-trait Eq<Sized? X> for Sized? { }
-impl<Sized? X> Eq<X> for X { }
-fn eq<Sized? A,Sized? B:Eq<A>>() { }
+trait Eq<X: ?Sized> for Sized? { }
+impl<X: ?Sized> Eq<X> for X { }
+fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
fn main() {
eq::< for<'a> Foo<(&'a int,), &'a int>,
fn dummy(&'a self) -> &'a (T,U);
}
-trait Eq<Sized? X> for Sized? { }
-impl<Sized? X> Eq<X> for X { }
-fn eq<Sized? A,Sized? B:Eq<A>>() { }
+trait Eq<X: ?Sized> for Sized? { }
+impl<X: ?Sized> Eq<X> for X { }
+fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
fn same_type<A,B:Eq<A>>(a: A, b: B) { }
// except according to those terms.
fn bar<T: Sized>() { }
-fn foo<Sized? T>() { bar::<T>() } //~ ERROR the trait `core::kinds::Sized` is not implemented
+fn foo<T: ?Sized>() { bar::<T>() } //~ ERROR the trait `core::kinds::Sized` is not implemented
fn main() { }
fn is_sized<T:Sized>() { }
-fn not_sized<Sized? T>() { }
+fn not_sized<T: ?Sized>() { }
enum Foo<U> { FooSome(U), FooNone }
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
-fn foo2<Sized? T>() { not_sized::<Foo<T>>() }
+fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
//~^ ERROR the trait `core::kinds::Sized` is not implemented
//
// Not OK: `T` is not sized.
-enum Bar<Sized? U> { BarSome(U), BarNone }
-fn bar1<Sized? T>() { not_sized::<Bar<T>>() }
-fn bar2<Sized? T>() { is_sized::<Bar<T>>() }
+enum Bar<U: ?Sized> { BarSome(U), BarNone }
+fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
+fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
//~^ ERROR the trait `core::kinds::Sized` is not implemented
//
// Not OK: `Bar<T>` is not sized, but it should be.
struct S5<Y>;
-impl<Sized? X> S5<X> { //~ ERROR not implemented
+impl<X: ?Sized> S5<X> { //~ ERROR not implemented
}
fn main() { }
fn is_sized<T:Sized>() { }
-fn not_sized<Sized? T>() { }
+fn not_sized<T: ?Sized>() { }
struct Foo<T> { data: T }
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
-fn foo2<Sized? T>() { not_sized::<Foo<T>>() }
+fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
//~^ ERROR the trait `core::kinds::Sized` is not implemented
//
// Not OK: `T` is not sized.
-struct Bar<Sized? T> { data: T }
-fn bar1<Sized? T>() { not_sized::<Bar<T>>() }
-fn bar2<Sized? T>() { is_sized::<Bar<T>>() }
+struct Bar<T: ?Sized> { data: T }
+fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
+fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
//~^ ERROR the trait `core::kinds::Sized` is not implemented
//
// Not OK: `Bar<T>` is not sized, but it should be.
// Test sized-ness checking in substitution in impls.
// impl - struct
-trait T3<Sized? Z> {
+trait T3<Z: ?Sized> {
}
struct S5<Y>;
-impl<Sized? X> T3<X> for S5<X> { //~ ERROR not implemented
+impl<X: ?Sized> T3<X> for S5<X> { //~ ERROR not implemented
}
fn main() { }
// impl - unbounded
trait T2<Z> {
}
-struct S4<Sized? Y>;
-impl<Sized? X> T2<X> for S4<X> {
+struct S4<Y: ?Sized>;
+impl<X: ?Sized> T2<X> for S4<X> {
//~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
}
// Unbounded.
-fn f1<Sized? X>(x: &X) {
+fn f1<X: ?Sized>(x: &X) {
f2::<X>(x);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
// Bounded.
trait T for Sized? {}
-fn f3<Sized? X: T>(x: &X) {
+fn f3<X: ?Sized + T>(x: &X) {
f4::<X>(x);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
}
// Test with unsized enum.
-enum E<Sized? X> {
+enum E<X: ?Sized> {
V(X),
}
fn f5<Y>(x: &Y) {}
-fn f6<Sized? X>(x: &X) {}
-fn f7<Sized? X>(x1: &E<X>, x2: &E<X>) {
+fn f6<X: ?Sized>(x: &X) {}
+fn f7<X: ?Sized>(x1: &E<X>, x2: &E<X>) {
f5(x1);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
f6(x2); // ok
// Test with unsized struct.
-struct S<Sized? X> {
+struct S<X: ?Sized> {
x: X,
}
-fn f8<Sized? X>(x1: &S<X>, x2: &S<X>) {
+fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
f5(x1);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
f6(x2); // ok
}
// Test some tuples.
-fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
+fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
f5(&(*x1, 34i));
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
-fn f10<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
+fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
f5(&(32i, *x2));
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
// Test that bounds are sized-compatible.
trait T : Sized {}
-fn f<Sized? Y: T>() {
+fn f<Y: ?Sized + T>() {
//~^ERROR incompatible bounds on `Y`, bound `T` does not allow unsized type
}
// Test `Sized?` types not allowed in fields (except the last one).
-struct S1<Sized? X> {
+struct S1<X: ?Sized> {
f1: X, //~ ERROR `core::kinds::Sized` is not implemented
f2: int,
}
-struct S2<Sized? X> {
+struct S2<X: ?Sized> {
f: int,
g: X, //~ ERROR `core::kinds::Sized` is not implemented
h: int,
f: str, //~ ERROR `core::kinds::Sized` is not implemented
g: uint
}
-enum E<Sized? X> {
+enum E<X: ?Sized> {
V1(X, int), //~ERROR `core::kinds::Sized` is not implemented
}
-enum F<Sized? X> {
+enum F<X: ?Sized> {
V2{f1: X, f: int}, //~ERROR `core::kinds::Sized` is not implemented
}
trait T for Sized? {}
-fn f1<Sized? X>(x: &X) {
+fn f1<X: ?Sized>(x: &X) {
let _: X; // <-- this is OK, no bindings created, no initializer.
let _: (int, (X, int)); // same
let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
}
-fn f2<Sized? X: T>(x: &X) {
+fn f2<X: ?Sized + T>(x: &X) {
let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
}
-fn f3<Sized? X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
+fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
let y: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
}
-fn f4<Sized? X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
+fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
let y: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
}
-fn g1<Sized? X>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
-fn g2<Sized? X: T>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
+fn g1<X: ?Sized>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
+fn g2<X: ?Sized + T>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
pub fn main() {
}
// impl - bounded
trait T1<Z: T> {
}
-struct S3<Sized? Y>;
-impl<Sized? X: T> T1<X> for S3<X> {
+struct S3<Y: ?Sized>;
+impl<X: ?Sized + T> T1<X> for S3<X> {
//~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
}
trait Trait {}
impl Trait for Foo {}
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
f: T
}
}
}
-struct Fat<Sized? T> {
+struct Fat<T: ?Sized> {
f: T
}
use std::ops::Deref;
-pub trait MyEq<Sized? U=Self> for Sized? {
+pub trait MyEq<U: ?Sized=Self> for Sized? {
fn eq(&self, u: &U) -> bool;
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub trait Borrow<Sized? Borrowed> {
+pub trait Borrow<Borrowed: ?Sized> {
fn borrow(&self) -> &Borrowed;
}