stack

Struct stack 

Source
pub struct stack<T: AbiType + 'static> { /* private fields */ }
Expand description

cpp class: template<class T, class Container> std::stack<T, Container>

Implementations§

Source§

impl<T: AbiType + 'static> stack<T>

Source

pub fn pop(&mut self)

如果为空不做任何改变.

use hicc_std::StackInt;
let mut stack = StackInt::new();
stack.pop();
stack.push(&1);
assert_eq!(stack.size(), 1);
stack.pop();
assert_eq!(stack.size(), 0);
Source

pub fn top(&self) -> Option<T::OutputRef<'_>>

use hicc_std::StackInt;
let mut stack = StackInt::new();
assert_eq!(stack.top(), None);
stack.push(&1);
assert_eq!(stack.top(), Some(&1));
Source

pub fn top_mut(&mut self) -> Option<T::OutputRefMut<'_>>

use hicc_std::StackInt;
let mut stack = StackInt::new();
assert_eq!(stack.top_mut(), None);
stack.push(&1);
*stack.top_mut().unwrap() += 1;
assert_eq!(stack.top_mut(), Some(&mut 2));

use hicc_std::{string, StackString};
use hicc::AbiClass;
let mut stack = StackString::new();
stack.push(&string::from(c"hello"));
assert_eq!(stack.top(), Some(string::from(c"hello").into_ref()));
stack.top_mut().unwrap().write(string::from(c"world"));
assert_eq!(stack.top(), Some(string::from(c"world").into_ref()));
Source

pub fn is_empty(&self) -> bool

use hicc_std::StackInt;
let mut stack = StackInt::new();
assert!(stack.is_empty());
stack.push(&1);
assert!(!stack.is_empty());
Source

pub fn size(&self) -> usize

use hicc_std::StackInt;
let mut stack = StackInt::new();
assert_eq!(stack.size(), 0);
stack.push(&1);
assert_eq!(stack.size(), 1);
Source

pub fn push(&mut self, val: &<T as AbiType>::InputType)

use hicc_std::StackInt;
let mut stack = StackInt::new();
stack.push(&1);
assert_eq!(stack.top(), Some(&1));
Source

pub fn swap(&mut self, other: &mut <stack<T> as AbiType>::InputType)

use hicc_std::StackInt;
let mut stack = StackInt::new();
stack.push(&1);
let mut other = StackInt::new();
other.push(&2);
assert_eq!(stack.top(), Some(&1));
assert_eq!(other.top(), Some(&2));
stack.swap(&mut other);
assert_eq!(stack.top(), Some(&2));
assert_eq!(other.top(), Some(&1));

Trait Implementations§

Source§

impl<T: AbiType + 'static> AbiClass for stack<T>

Source§

fn get_raw_obj(&self) -> *const ()

仅内部使用.指针携带附加信息,不能转换为c++类指针.
Source§

unsafe fn make_ref(&self, obj: *const ()) -> Self

Safety Read more
Source§

unsafe fn into_unique(self) -> Self

Safety Read more
Source§

fn write(&mut self, other: Self)

更新对象本身. Read more
Source§

fn size_of(&self) -> usize

返回c++对象的大小.
Source§

fn is_null(&self) -> bool

rust侧的值类型实际都对应到c++侧的对象指针, 检查是否为空指针.
Source§

fn as_ref(&self) -> ClassRef<'_, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价. Read more
Source§

fn as_mut(&mut self) -> ClassRefMut<'_, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价. Read more
Source§

fn as_ptr(&self) -> ClassPtr<'_, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价. Read more
Source§

fn as_mut_ptr(&mut self) -> ClassMutPtr<'_, Self>

AbiType::InputMutPtr<'_, T>参数类型实际是&ClassMutPtr<'_, T>, 当需要传递这类参数时可调用此接口.
Source§

fn into_ref(self) -> ClassRef<'static, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.
Source§

fn into_mut(self) -> ClassRefMut<'static, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.
Source§

fn into_ptr(self) -> ClassPtr<'static, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.
Source§

fn into_mut_ptr(self) -> ClassMutPtr<'static, Self>

T, ClassRef<'_, T>, ClassRefMut<'_, T>, ClassPtr<'_, T>, ClassMutPtr<'_, T>作为返回值实质是等价.
Source§

fn get_obj(&self) -> *const ()

一般内部使用. 返回值等同于c++侧的指针。
Source§

impl<T: AbiType + 'static> Debug for stack<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: AbiType + 'static> Drop for stack<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: AbiType + Sync> Send for stack<T>

Source§

impl<T: AbiType + Sync> Sync for stack<T>

Auto Trait Implementations§

§

impl<T> Freeze for stack<T>

§

impl<T> RefUnwindSafe for stack<T>

§

impl<T> Unpin for stack<T>

§

impl<T> UnwindSafe for stack<T>

Blanket Implementations§

Source§

impl<T> AbiType for T
where T: AbiClass,

Source§

type InputType = T

Source§

type InputPtr<'a, P, const N: usize> = &'a ClassPtr<'a, T, N> where T: 'a

Source§

type InputMutPtr<'a, P, const N: usize> = &'a ClassMutPtr<'a, T, N> where T: 'a

Source§

type OutputType = T

Source§

type OutputRef<'a> = ClassRef<'a, T> where T: 'a

Source§

type OutputRefMut<'a> = ClassRefMut<'a, T> where T: 'a

Source§

type OutputPtr<'a, P, const N: usize> = ClassPtr<'a, T, N> where T: 'a

Source§

type OutputMutPtr<'a, P, const N: usize> = ClassMutPtr<'a, T, N> where T: 'a

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.