Skip to content

Commit a99dc54

Browse files
authored
Make low-level layout algorithm functions public (#434)
* Make low-level layout algorithm functions public * Add const constructor to NodeId * Feature flag algorithm exports
1 parent 3bda644 commit a99dc54

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

src/compute/flexbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::tree::{LayoutTree, NodeId};
2121
use crate::debug::NODE_LOGGER;
2222

2323
/// The public interface to Taffy's Flexbox algorithm implementation
24-
pub(crate) struct FlexboxAlgorithm;
24+
pub struct FlexboxAlgorithm;
2525
impl LayoutAlgorithm for FlexboxAlgorithm {
2626
const NAME: &'static str = "FLEXBOX";
2727

src/compute/grid/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mod types;
3434
mod util;
3535

3636
/// The public interface to Taffy's CSS Grid algorithm implementation
37-
pub(crate) struct CssGridAlgorithm;
37+
pub struct CssGridAlgorithm;
3838
impl LayoutAlgorithm for CssGridAlgorithm {
3939
const NAME: &'static str = "CSS GRID";
4040

src/compute/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn compute_layout(
5454
}
5555

5656
/// A common interface that all Taffy layout algorithms conform to
57-
pub(crate) trait LayoutAlgorithm {
57+
pub trait LayoutAlgorithm {
5858
/// The name of the algorithm (mainly used for debug purposes)
5959
const NAME: &'static str;
6060

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@ mod resolve;
4242
mod sys;
4343

4444
pub use crate::compute::compute_layout;
45+
#[cfg(feature = "flexbox")]
46+
pub use crate::compute::flexbox::FlexboxAlgorithm;
47+
#[cfg(feature = "grid")]
48+
pub use crate::compute::grid::CssGridAlgorithm;
49+
pub use crate::compute::LayoutAlgorithm;
4550
pub use crate::node::Taffy;

src/tree.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ use slotmap::{DefaultKey, Key, KeyData};
1111
/// and u64 if needed.
1212
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1313
pub struct NodeId(u64);
14+
impl NodeId {
15+
/// Create a new NodeId from a u64 value
16+
pub const fn new(val: u64) -> Self {
17+
Self(val)
18+
}
19+
}
1420

1521
impl From<u64> for NodeId {
1622
#[inline]

0 commit comments

Comments
 (0)