SingleElementGridBuilder

Struct SingleElementGridBuilder 

Source
pub struct SingleElementGridBuilder<T: Scalar> { /* private fields */ }
Expand description

Grid builder for a single element grid

The following gives an example of creating a new grid consisting of a single triangle.

use ndgrid::traits::Builder;
use ndgrid::SingleElementGridBuilder;
use ndelement::types::ReferenceCellType;

// The geometric dimension of our space is 3.
let gdim = 3;

// We are building a two dimensional surface triangle grid within a three dimensional space.
// Our grid will have three points and one `Triangle` cell of order 1.
let mut builder = SingleElementGridBuilder::new_with_capacity(gdim, 3, 1, (ReferenceCellType::Triangle, 1));
builder.add_point(0, &[0.0, 0.0, 0.0]);
builder.add_point(1, &[1.0, 0.0, 0.0]);
builder.add_point(2, &[0.0, 1.0, 0.0]);
builder.add_cell(0, &[0, 1, 2]);

let grid = builder.create_grid();

Implementations§

Source§

impl<T: Scalar> SingleElementGridBuilder<T>

Source

pub fn new(gdim: usize, data: (ReferenceCellType, usize)) -> Self

Create a new grid builder

Examples found in repository?
ndgrid/examples/test_parallel_io.rs (line 36)
30fn example_single_element_grid<C: Communicator>(
31    comm: &C,
32    n: usize,
33) -> ParallelGridImpl<'_, C, SingleElementGrid<f64, CiarletElement<f64, IdentityMap, f64>>> {
34    let rank = comm.rank();
35
36    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Quadrilateral, 1));
37
38    if rank == 0 {
39        create_single_element_grid_data(&mut b, n);
40        b.create_parallel_grid_root(comm, GraphPartitioner::None)
41    } else {
42        b.create_parallel_grid(comm, 0)
43    }
44}
More examples
Hide additional examples
ndgrid/examples/test_parallel_grid.rs (line 12)
10fn test_noncontiguous_numbering<C: Communicator>(comm: &C) {
11    let rank = comm.rank();
12    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Quadrilateral, 1));
13
14    let g = if rank == 0 {
15        let n = 5;
16        for y in 0..n {
17            for x in 0..n {
18                b.add_point(
19                    2 * (y * n + x) + 5,
20                    &[x as f64 / (n - 1) as f64, y as f64 / (n - 1) as f64, 0.0],
21                );
22            }
23        }
24
25        for i in 0..n - 1 {
26            for j in 0..n - 1 {
27                b.add_cell(
28                    3 * (i * (n - 1) + j),
29                    &[
30                        2 * (j * n + i) + 5,
31                        2 * (j * n + i + 1) + 5,
32                        2 * (j * n + i + n) + 5,
33                        2 * (j * n + i + n + 1) + 5,
34                    ],
35                );
36            }
37        }
38
39        b.create_parallel_grid_root(comm, GraphPartitioner::None)
40    } else {
41        b.create_parallel_grid(comm, 0)
42    };
43
44    assert!(g.local_grid().entity_count(ReferenceCellType::Point) > 0);
45}
ndgrid/examples/single_element_grid.rs (line 13)
10fn main() {
11    // When creating the grid builder, we give the physical/geometric dimension (3) and the cell type
12    // and degree of the element
13    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Quadrilateral, 1));
14    // Add six points with ids 0 to 5
15    b.add_point(0, &[0.0, 0.0, 0.0]);
16    b.add_point(1, &[1.0, 0.0, 0.0]);
17    b.add_point(2, &[2.0, 0.0, 0.2]);
18    b.add_point(3, &[0.0, 1.0, 0.0]);
19    b.add_point(4, &[1.0, 1.0, -0.2]);
20    b.add_point(5, &[2.0, 1.0, 0.0]);
21    // Add two cells
22    b.add_cell(0, &[0, 1, 3, 4]);
23    b.add_cell(1, &[1, 2, 4, 5]);
24    // Create the grid
25    let grid = b.create_grid();
26
27    // Print the coordinates or each point in the mesh
28    let mut coords = vec![0.0; grid.geometry_dim()];
29    for point in grid.entity_iter(ReferenceCellType::Point) {
30        point.geometry().points().collect::<Vec<_>>()[0].coords(coords.as_mut_slice());
31        println!("point {}: {:#?}", point.local_index(), coords);
32    }
33
34    // Print the vertices of each cell
35    for cell in grid.entity_iter(ReferenceCellType::Quadrilateral) {
36        println!(
37            "cell {}: {:?} ",
38            cell.local_index(),
39            cell.topology()
40                .sub_entity_iter(ReferenceCellType::Point)
41                .collect::<Vec<_>>()
42        );
43    }
44}
ndgrid/examples/parallel_io.rs (line 29)
17fn main() {
18    let universe: Universe = mpi::initialize().unwrap();
19    let comm = universe.world();
20    let rank = comm.rank();
21
22    let g = if rank == 0 {
23        // Create a grid using the shapes module: unit_cube_boundary will mesh the surface of a cube
24        let serial_g = shapes::unit_cube_boundary::<f64>(4, 5, 4, ReferenceCellType::Triangle);
25
26        // Distribute this grid across processes
27        serial_g.distribute(&comm, GraphPartitioner::None)
28    } else {
29        let b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
30        b.create_parallel_grid(&comm, 0)
31    };
32
33    // If the serde option is used, the raw grid data can be exported in RON format
34    g.export_as_ron("_unit_cube_boundary_parallel.ron");
35
36    // Wait for export to finish
37    comm.barrier();
38
39    // A grid can be re-imported from raw RON data. Note that it must be imported on the same number of processes as it was exported using
40    let g2 = ParallelGridImpl::<'_, _, SingleElementGrid::<f64, CiarletElement<f64, IdentityMap, f64>>>::import_from_ron(&comm, "_unit_cube_boundary_parallel.ron");
41
42    // Print the first 5 cells of each grid on process 0
43    if rank == 0 {
44        println!("The first 5 cells of the grids");
45        for (cell, cell2) in izip!(
46            g.local_grid().entity_iter(ReferenceCellType::Triangle),
47            g2.local_grid().entity_iter(ReferenceCellType::Triangle)
48        )
49        .take(5)
50        {
51            println!(
52                "{:?} {:?}",
53                cell.topology()
54                    .sub_entity_iter(ReferenceCellType::Point)
55                    .collect::<Vec<_>>(),
56                cell2
57                    .topology()
58                    .sub_entity_iter(ReferenceCellType::Point)
59                    .collect::<Vec<_>>(),
60            );
61        }
62    }
63}
ndgrid/examples/io.rs (line 53)
13fn main() {
14    // Create a grid using the shapes module: unit_cube_boundary will mesh the surface of a cube
15    let g = shapes::unit_cube_boundary::<f64>(4, 5, 4, ReferenceCellType::Triangle);
16
17    // If the serde option is used, the raw grid data can be exported in RON format
18    g.export_as_ron("_unit_cube_boundary.ron");
19
20    // A grid can be re-imported from raw RON data
21    let g2 = SingleElementGrid::<f64, CiarletElement<f64, IdentityMap, f64>>::import_from_ron(
22        "_unit_cube_boundary.ron",
23    );
24
25    // Print the first 5 cells of each grid
26    println!("The first 5 cells of the grids");
27    for (cell, cell2) in izip!(
28        g.entity_iter(ReferenceCellType::Triangle),
29        g2.entity_iter(ReferenceCellType::Triangle)
30    )
31    .take(5)
32    {
33        println!(
34            "{:?} {:?}",
35            cell.topology()
36                .sub_entity_iter(ReferenceCellType::Point)
37                .collect::<Vec<_>>(),
38            cell2
39                .topology()
40                .sub_entity_iter(ReferenceCellType::Point)
41                .collect::<Vec<_>>(),
42        );
43    }
44
45    println!();
46
47    // Alternatively, grids can be exported and imported to/from Gmsh files
48
49    // Export the grid as a Gmsh .msh file
50    g.export_as_gmsh("_unit_cube_boundary.msh");
51
52    // To import from a Gmsh .msh file, a builder is used
53    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
54    b.import_from_gmsh("_unit_cube_boundary.msh");
55    let g3 = b.create_grid();
56
57    // Print the first 5 cells of each grid
58    println!("The first 5 cells of the grids");
59    for (cell, cell3) in izip!(
60        g.entity_iter(ReferenceCellType::Triangle),
61        g3.entity_iter(ReferenceCellType::Triangle)
62    )
63    .take(5)
64    {
65        println!(
66            "{:?} {:?}",
67            cell.topology()
68                .sub_entity_iter(ReferenceCellType::Point)
69                .collect::<Vec<_>>(),
70            cell3
71                .topology()
72                .sub_entity_iter(ReferenceCellType::Point)
73                .collect::<Vec<_>>(),
74        );
75    }
76}
ndgrid/examples/test_push_forward.rs (line 16)
15fn test_lagrange_push_forward() {
16    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
17    b.add_point(0, &[0.0, 0.0, 0.0]);
18    b.add_point(1, &[1.0, 0.0, 0.0]);
19    b.add_point(2, &[2.0, 0.0, 1.0]);
20    b.add_point(3, &[0.0, 1.0, 0.0]);
21    b.add_cell(0, &[0, 1, 3]);
22    b.add_cell(1, &[1, 2, 3]);
23    let grid = b.create_grid();
24
25    let e = lagrange::create::<f64, f64>(ReferenceCellType::Triangle, 4, Continuity::Standard);
26
27    let npts = 5;
28
29    let mut cell0_points = rlst_dynamic_array!(f64, [2, npts]);
30    for i in 0..npts {
31        cell0_points[[1, i]] = i as f64 / (npts - 1) as f64;
32        cell0_points[[0, i]] = 1.0 - cell0_points[[1, i]];
33    }
34    let mut cell0_table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
35    e.tabulate(&cell0_points, 0, &mut cell0_table);
36
37    let mut points = rlst_dynamic_array!(f64, [2, npts]);
38    for i in 0..npts {
39        points[[0, i]] = 0.0;
40        points[[1, i]] = i as f64 / (npts - 1) as f64;
41    }
42
43    let mut table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
44    e.tabulate(&points, 0, &mut table);
45
46    let gmap = grid.geometry_map(ReferenceCellType::Triangle, 1, &points);
47
48    let mut jacobians = rlst_dynamic_array!(f64, [grid.geometry_dim(), grid.topology_dim(), npts]);
49    let mut jinv = rlst_dynamic_array!(f64, [grid.topology_dim(), grid.geometry_dim(), npts]);
50    let mut jdets = vec![0.0; npts];
51
52    gmap.jacobians_inverses_dets(1, &mut jacobians, &mut jinv, &mut jdets);
53
54    let mut cell1_table = DynArray::<f64, 4>::from_shape(table.shape());
55    e.push_forward(&table, 0, &jacobians, &jdets, &jinv, &mut cell1_table);
56
57    // Check that basis functions are continuous between cells
58    for (cell0_dof, cell1_dof) in izip!(
59        e.entity_closure_dofs(1, 1).unwrap(),
60        e.entity_closure_dofs(1, 0).unwrap()
61    ) {
62        for i in 0..npts {
63            assert_relative_eq!(
64                cell0_table[[0, i, *cell0_dof, 0]],
65                cell1_table[[0, i, *cell1_dof, 0]],
66                epsilon = 1e-10
67            );
68        }
69    }
70}
71
72/// Test Ravaiart-Thomas push forward
73fn test_rt_push_forward() {
74    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
75    b.add_point(0, &[0.0, 0.0, 0.0]);
76    b.add_point(1, &[1.0, 0.0, 0.0]);
77    b.add_point(2, &[2.0, 0.0, 1.0]);
78    b.add_point(3, &[0.0, 1.0, 0.0]);
79    b.add_cell(0, &[0, 1, 3]);
80    b.add_cell(1, &[1, 2, 3]);
81    let grid = b.create_grid();
82
83    let e =
84        raviart_thomas::create::<f64, f64>(ReferenceCellType::Triangle, 4, Continuity::Standard);
85
86    let npts = 5;
87
88    let mut cell0_points = rlst_dynamic_array!(f64, [2, npts]);
89    for i in 0..npts {
90        cell0_points[[1, i]] = i as f64 / (npts - 1) as f64;
91        cell0_points[[0, i]] = 1.0 - cell0_points[[1, i]];
92    }
93    let mut cell0_table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
94    e.tabulate(&cell0_points, 0, &mut cell0_table);
95
96    let mut points = rlst_dynamic_array!(f64, [2, npts]);
97    for i in 0..npts {
98        points[[0, i]] = 0.0;
99        points[[1, i]] = i as f64 / (npts - 1) as f64;
100    }
101
102    let mut table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
103    e.tabulate(&points, 0, &mut table);
104
105    let gmap = grid.geometry_map(ReferenceCellType::Triangle, 1, &points);
106
107    let mut jacobians = rlst_dynamic_array!(f64, [grid.geometry_dim(), grid.topology_dim(), npts]);
108    let mut jinv = rlst_dynamic_array!(f64, [grid.topology_dim(), grid.geometry_dim(), npts]);
109    let mut jdets = vec![0.0; npts];
110
111    gmap.jacobians_inverses_dets(1, &mut jacobians, &mut jinv, &mut jdets);
112
113    let mut cell1_table =
114        DynArray::<f64, 4>::from_shape([table.shape()[0], table.shape()[1], table.shape()[2], 3]);
115    e.push_forward(&table, 0, &jacobians, &jdets, &jinv, &mut cell1_table);
116
117    // Check that basis functions dotted with normal to edge are continuous between cells
118    for (cell0_dof, cell1_dof) in izip!(
119        e.entity_closure_dofs(1, 0).unwrap(),
120        e.entity_closure_dofs(1, 1).unwrap()
121    ) {
122        for i in 0..npts {
123            assert_relative_eq!(
124                (cell0_table[[0, i, *cell0_dof, 0]] + cell0_table[[0, i, *cell0_dof, 1]])
125                    / f64::sqrt(2.0),
126                (cell1_table[[0, i, *cell1_dof, 0]]
127                    + cell1_table[[0, i, *cell1_dof, 1]]
128                    + 2.0 * cell1_table[[0, i, *cell1_dof, 2]])
129                    / f64::sqrt(6.0),
130                epsilon = 1e-10
131            );
132        }
133    }
134}
135
136/// Test Nedelec push forward
137fn test_nc_push_forward() {
138    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
139    b.add_point(0, &[0.0, 0.0, 0.0]);
140    b.add_point(1, &[1.0, 0.0, 0.0]);
141    b.add_point(2, &[2.0, 0.0, 1.0]);
142    b.add_point(3, &[0.0, 1.0, 0.0]);
143    b.add_cell(0, &[0, 1, 3]);
144    b.add_cell(1, &[1, 2, 3]);
145    let grid = b.create_grid();
146
147    let e = nedelec::create::<f64, f64>(ReferenceCellType::Triangle, 4, Continuity::Standard);
148
149    let npts = 5;
150
151    let mut cell0_points = rlst_dynamic_array!(f64, [2, npts]);
152    for i in 0..npts {
153        cell0_points[[1, i]] = i as f64 / (npts - 1) as f64;
154        cell0_points[[0, i]] = 1.0 - cell0_points[[1, i]];
155    }
156    let mut cell0_table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
157    e.tabulate(&cell0_points, 0, &mut cell0_table);
158
159    let mut points = rlst_dynamic_array!(f64, [2, npts]);
160    for i in 0..npts {
161        points[[0, i]] = 0.0;
162        points[[1, i]] = i as f64 / (npts - 1) as f64;
163    }
164
165    let mut table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
166    e.tabulate(&points, 0, &mut table);
167
168    let gmap = grid.geometry_map(ReferenceCellType::Triangle, 1, &points);
169
170    let mut jacobians = rlst_dynamic_array!(f64, [grid.geometry_dim(), grid.topology_dim(), npts]);
171    let mut jinv = rlst_dynamic_array!(f64, [grid.topology_dim(), grid.geometry_dim(), npts]);
172    let mut jdets = vec![0.0; npts];
173
174    gmap.jacobians_inverses_dets(1, &mut jacobians, &mut jinv, &mut jdets);
175
176    let mut cell1_table =
177        DynArray::<f64, 4>::from_shape([table.shape()[0], table.shape()[1], table.shape()[2], 3]);
178    e.push_forward(&table, 0, &jacobians, &jdets, &jinv, &mut cell1_table);
179
180    // Check that basis functions dotted with tangent to edge are continuous between cells
181    for (cell0_dof, cell1_dof) in izip!(
182        e.entity_closure_dofs(1, 0).unwrap(),
183        e.entity_closure_dofs(1, 1).unwrap()
184    ) {
185        for i in 0..npts {
186            assert_relative_eq!(
187                (cell0_table[[0, i, *cell0_dof, 0]] - cell0_table[[0, i, *cell0_dof, 1]])
188                    / f64::sqrt(2.0),
189                (cell1_table[[0, i, *cell1_dof, 0]] - cell1_table[[0, i, *cell1_dof, 1]])
190                    / f64::sqrt(2.0),
191                epsilon = 1e-10
192            );
193        }
194    }
195}
Source

pub fn new_with_capacity( gdim: usize, npoints: usize, ncells: usize, data: (ReferenceCellType, usize), ) -> Self

Create a new grid builder with capacaty for a given number of points and cells

Trait Implementations§

Source§

impl<T: Scalar> Builder for SingleElementGridBuilder<T>

Source§

type Grid = SingleElementGrid<T, CiarletElement<T, IdentityMap, T>>

The type of the grid that the builder creates
Source§

type T = T

The floating point type used for coordinates
Source§

type CellData<'a> = &'a [usize]

The type of the data that is input to add a cell
Source§

type EntityDescriptor = ReferenceCellType

Type used as identifier of different entity types
Source§

fn add_point(&mut self, id: usize, data: &[T])

Add a point to the grid
Source§

fn add_cell(&mut self, id: usize, cell_data: &[usize])

Add a cell to the grid
Source§

fn add_cell_from_nodes_and_type( &mut self, id: usize, nodes: &[usize], cell_type: ReferenceCellType, cell_degree: usize, )

Add a cell to the grid
Source§

fn create_grid(&self) -> SingleElementGrid<T, CiarletElement<T, IdentityMap, T>>

Create the grid
Source§

fn point_count(&self) -> usize

Number of points
Source§

fn cell_count(&self) -> usize

Number of cells
Source§

fn point_indices_to_ids(&self) -> &[usize]

Get the insertion ids of each point
Source§

fn cell_indices_to_ids(&self) -> &[usize]

Get the insertion ids of each cell
Source§

fn cell_points(&self, index: usize) -> &[usize]

Get the indices of the points of a cell
Source§

fn cell_vertices(&self, index: usize) -> &[usize]

Get the indices of the points of a cell
Source§

fn point(&self, index: usize) -> &[T]

Get the coordinates of a point
Source§

fn points(&self) -> &[T]

Get all points
Source§

fn cell_type(&self, _index: usize) -> ReferenceCellType

Get the type of a cell
Source§

fn cell_degree(&self, _index: usize) -> usize

Get the degree of a cell’s geometry
Source§

fn gdim(&self) -> usize

Geometric dimension
Source§

fn tdim(&self) -> usize

Topoligical dimension
Source§

fn npts(&self, _cell_type: Self::EntityDescriptor, _degree: usize) -> usize

Number of points in a cell with the given type and degree
Source§

impl<T: Debug + Scalar> Debug for SingleElementGridBuilder<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

§

type Err = NoError

The error type produced by a failed conversion.
§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, Dst> ConvAsUtil<Dst> for T

§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
§

impl<T> ConvUtil for T

§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, B> GmshImport for B
where T: FromStr + FromBytes + Debug, <T as FromBytes>::Bytes: Sized, B: Builder<T = T, EntityDescriptor = ReferenceCellType>,

Source§

fn import_from_gmsh_v1(&mut self, s: String)

Generate grid from a Gmsh v1 string
Source§

fn import_from_gmsh_string_v2(&mut self, s: String)

Generate grid from a Gmsh v2 string
Source§

fn import_from_gmsh_binary_v2( &mut self, reader: BufReader<File>, data_size: usize, is_le: bool, )

Generate grid from a Gmsh v2 binary
Source§

fn import_from_gmsh_string_v4(&mut self, s: String)

Generate grid from a Gmsh v4 string
Source§

fn import_from_gmsh_binary_v4( &mut self, reader: BufReader<File>, data_size: usize, is_le: bool, )

Generate grid from a Gmsh v4 binary
Source§

fn import_from_gmsh(&mut self, filename: &str)

Generate grid from Gmsh
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<Src> TryFrom<Src> for Src

§

type Err = NoError

The error type produced by a failed conversion.
§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<Src> ValueFrom<Src> for Src

§

type Err = NoError

The error type produced by a failed conversion.
§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T, U> Imply<T> for U