rust_macios/appkit/
ns_layout_anchor.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4    object,
5    objective_c_runtime::{
6        macros::interface_impl,
7        traits::{FromId, PNSObject},
8    },
9};
10
11use super::NSLayoutConstraint;
12
13object! {
14    /// A factory class for creating layout constraint objects using a fluent API.
15    unsafe pub struct NSLayoutAnchor;
16}
17
18#[interface_impl(NSObject)]
19impl NSLayoutAnchor {
20    /* Building Constraints
21     */
22
23    /// Returns a constraint that defines one item’s attribute as equal to another.
24    #[method]
25    pub fn constraint_equal_to_anchor<A>(&self, anchor: A) -> NSLayoutConstraint
26    where
27        A: INSLayoutAnchor,
28    {
29        unsafe {
30            NSLayoutConstraint::from_id(msg_send![self.m_self(), constraintEqualToAnchor: anchor])
31        }
32    }
33}