Skip to main content

rust_macios/core_foundation/
cf_range.rs

1use super::CFIndex;
2
3/// A structure representing a range of sequential items in a container, such as characters in a buffer or elements in a collection.
4#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
5#[repr(C)]
6pub struct CFRange {
7    /// An integer representing the starting location of the range. For type compatibility with the rest of the system, LONG_MAX is the maximum value you should use for location.
8    pub location: CFIndex,
9    /// An integer representing the number of items in the range. For type compatibility with the rest of the system, LONG_MAX is the maximum value you should use for length.
10    pub length: CFIndex,
11}
12
13impl CFRange {
14    /// Declares and initializes a CFRange structure.
15    pub fn make(loc: CFIndex, len: CFIndex) -> CFRange {
16        unsafe { CFRangeMake(loc, len) }
17    }
18}
19
20extern "C" {
21    fn CFRangeMake(loc: CFIndex, len: CFIndex) -> CFRange;
22}