Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

tindzk/atomic_prim_traits

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

atomic_prim_traits

License Package Documentation

Traits over atomic primitive integer types.

Example

fn incr<T: AtomicInt>(value: &T) -> Result<<T as AtomicInt>::Prim, <T as AtomicInt>::Prim> {
    value.fetch_update(
        Ordering::SeqCst,
        Ordering::SeqCst,
        |i| Some(if i == T::MAX { T::MIN } else { i + T::ONE })
    )
}

let value = AtomicU8::new(255);
assert_eq!(incr(&value), Ok(255));
assert_eq!(incr(&value), Ok(0));

Notes

  • Enable feature nightly to get as_mut_ptr when you have a nightly compiler available.
  • Rust 1.45.0 or newer is required.

Copyright and License

Copyright (c) 2020-2023 James Laver, atomic_prim_traits contributors.

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

About

Atomic primitive integer traits

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%