vanilladocs
vanillapunch.com
API / ui/autolayout/layoutrelation

ui/autolayout/layoutrelation

제약 관계 연산자. (원본 ui/autolayout/layoutrelation.js 의 LayoutRelation)

  • LayoutConstraint 가 식 == 0, <= 0, >= 0 중 어느 쪽인지 가린다.
  • 원본은 문자열 값("==", "<=", ">=")을 담은 객체다. 러스트 판은 열거형이다.

Constraint relation operator. (LayoutRelation of the original ui/autolayout/layoutrelation.js)

  • Tells whether a LayoutConstraint is expression == 0, <= 0 or >= 0.
  • The original is an object holding string values ("==", "<=", ">="). The Rust version is an enum.
예제Example비교 함수가 고른 관계와 직접 만든 제약The relation chosen by comparison functions and a directly created constraint
use vanilla::{LayoutConstraint, LayoutExpression, LayoutRelation, LayoutStrength, LayoutVariable};

let x = LayoutVariable::new("x");
let at_most = LayoutExpression::from_variable(&x).less_than_or_equal_to(100);
assert_eq!(at_most.get_relation(), LayoutRelation::LessThanOrEqual);
assert_eq!(at_most.get_expression().get_constant(), -100.0);

let expression = LayoutExpression::from_variable(&x).subtract(20);
let at_least = LayoutConstraint::new(expression, LayoutRelation::GreaterThanOrEqual, LayoutStrength::STRONG);
assert_eq!(at_least.get_relation(), LayoutRelation::GreaterThanOrEqual);

LayoutRelationenum traits Clone, Copy, Debug, PartialEq, Eq, Hash

짝Counterpart: vanilla.js LayoutRelation소스source

제약 관계 연산자.

Constraint relation operator.

이름Name설명Description
Equal식 == 0expression == 0
LessThanOrEqual식 <= 0expression <= 0
GreaterThanOrEqual식 >= 0expression >= 0