Skip to main content

BearDb

Struct BearDb 

Source
pub struct BearDb { /* private fields */ }
Expand description

Handle to Bear’s database. All operations use short-lived connections internally.

Implementations§

Source§

impl BearDb

Source

pub fn new() -> Result<Self, BearError>

Create a new BearDb handle. Opens a temporary connection to discover schema metadata, generates normalizing CTEs, then closes the connection.

Examples found in repository?
examples/query_demo.rs (line 4)
3fn main() -> Result<(), BearError> {
4  let db = BearDb::new()?;
5
6  // Example 1: Using typed API
7  println!("=== Typed API Examples ===\n");
8
9  let tags = db.tags()?;
10  println!("Total tags: {}\n", tags.count());
11
12  // Using the new NotesQuery API - much more readable!
13  db.notes(NotesQuery::default())?
14    .into_iter()
15    .for_each(|note| {
16      println!("Note: {:?}", note.title());
17      db.note_links(note.id())
18        .unwrap()
19        .into_iter()
20        .for_each(|link| println!("  Linked: {:?}", link.title()));
21
22      let note_tags = db.note_tags(note.id()).unwrap();
23      println!("  Tags: {:?}\n", tags.names(&note_tags));
24    });
25
26  // Example 2: Using generic SQL query API with DataFrames
27  println!("\n=== Generic SQL Query API Examples ===\n");
28
29  // Simple query
30  println!("Top 5 most recent notes:");
31  let df = db
32    .query("SELECT title, created FROM notes WHERE is_trashed = 0 ORDER BY created DESC LIMIT 5")?;
33  println!("{}\n", df);
34
35  // Join query
36  println!("Notes with their tags:");
37  let df = db.query(
38    r"
39    SELECT n.title, t.name as tag_name
40    FROM notes n
41    JOIN note_tags nt ON n.id = nt.note_id
42    JOIN tags t ON nt.tag_id = t.id
43    WHERE n.is_trashed = 0
44    ORDER BY n.modified DESC
45    LIMIT 10
46  ",
47  )?;
48  println!("{}\n", df);
49
50  // Aggregation query
51  println!("Tag usage statistics:");
52  let df = db.query(
53    r"
54    SELECT t.name, COUNT(*) as note_count
55    FROM tags t
56    JOIN note_tags nt ON t.id = nt.tag_id
57    GROUP BY t.id, t.name
58    ORDER BY note_count DESC
59    LIMIT 10
60  ",
61  )?;
62  println!("{}\n", df);
63
64  Ok(())
65}
More examples
Hide additional examples
examples/null_analysis.rs (line 9)
7fn main() -> Result<(), bear_query::BearError> {
8  // Connect to Bear's database
9  let db = BearDb::new()?;
10
11  println!("=== Bear Database NULL Value Analysis ===\n");
12
13  // Query for notes with NULL titles
14  let null_titles_df = db.query("SELECT COUNT(*) as count FROM notes WHERE title IS NULL")?;
15  let null_titles_count = null_titles_df.column("count")?.i64()?.get(0).unwrap();
16
17  println!("Notes with NULL titles: {}", null_titles_count);
18
19  // Query for notes with NULL content
20  let null_content_df = db.query("SELECT COUNT(*) as count FROM notes WHERE content IS NULL")?;
21  let null_content_count = null_content_df.column("count")?.i64()?.get(0).unwrap();
22
23  println!("Notes with NULL content: {}", null_content_count);
24
25  // Query for notes with NULL id (UUID)
26  let null_id_df = db.query("SELECT COUNT(*) as count FROM notes WHERE id IS NULL")?;
27  let null_id_count = null_id_df.column("count")?.i64()?.get(0).unwrap();
28
29  println!("Notes with NULL id: {}", null_id_count);
30
31  // Get total note count for comparison
32  let total_df = db.query("SELECT COUNT(*) as count FROM notes")?;
33  let total_count = total_df.column("count")?.i64()?.get(0).unwrap();
34
35  println!("\nTotal notes in database: {}", total_count);
36
37  // Show percentages
38  if total_count > 0 {
39    println!("\n=== Percentages ===");
40    println!(
41      "NULL titles: {:.2}%",
42      (null_titles_count as f64 / total_count as f64) * 100.0
43    );
44    println!(
45      "NULL content: {:.2}%",
46      (null_content_count as f64 / total_count as f64) * 100.0
47    );
48    println!(
49      "NULL id: {:.2}%",
50      (null_id_count as f64 / total_count as f64) * 100.0
51    );
52  }
53
54  // Show some examples of notes with NULL titles (if any exist)
55  if null_titles_count > 0 {
56    println!("\n=== Sample Notes with NULL Titles ===");
57    let sample_df = db.query("SELECT id, content FROM notes WHERE title IS NULL LIMIT 5")?;
58
59    println!("{}", sample_df);
60  }
61
62  // Show some examples of notes with NULL content (if any exist)
63  if null_content_count > 0 {
64    println!("\n=== Sample Notes with NULL Content ===");
65    let sample_df = db.query("SELECT id, title FROM notes WHERE content IS NULL LIMIT 5")?;
66
67    println!("{}", sample_df);
68  }
69
70  // More detailed analysis: notes with multiple NULL fields
71  println!("\n=== Notes with Multiple NULL Fields ===");
72  let multiple_nulls_df = db.query(
73    r"
74        SELECT
75            COUNT(*) as count,
76            CASE
77                WHEN title IS NULL AND content IS NULL THEN 'Both title and content'
78                WHEN title IS NULL AND id IS NULL THEN 'Both title and id'
79                WHEN content IS NULL AND id IS NULL THEN 'Both content and id'
80                ELSE 'Other combination'
81            END as null_combination
82        FROM notes
83        WHERE (title IS NULL OR content IS NULL OR id IS NULL)
84        GROUP BY null_combination
85        ",
86  )?;
87
88  if multiple_nulls_df.height() > 0 {
89    println!("{}", multiple_nulls_df);
90  } else {
91    println!("No notes with multiple NULL fields found.");
92  }
93
94  // Analysis by note status (trashed, archived, etc.)
95  println!("\n=== NULL Values by Note Status ===");
96  let by_status_df = db.query(
97    r"
98        SELECT
99            CASE
100                WHEN is_trashed = 1 THEN 'Trashed'
101                WHEN is_archived = 1 THEN 'Archived'
102                ELSE 'Active'
103            END as status,
104            COUNT(*) as total_notes,
105            SUM(CASE WHEN title IS NULL THEN 1 ELSE 0 END) as null_titles,
106            SUM(CASE WHEN content IS NULL THEN 1 ELSE 0 END) as null_content,
107            SUM(CASE WHEN id IS NULL THEN 1 ELSE 0 END) as null_id
108        FROM notes
109        GROUP BY status
110        ORDER BY total_notes DESC
111        ",
112  )?;
113
114  println!("{}", by_status_df);
115
116  Ok(())
117}
Source

pub fn tags(&self) -> Result<TagsMap, BearError>

Retrieves all tags from Bear

Examples found in repository?
examples/query_demo.rs (line 9)
3fn main() -> Result<(), BearError> {
4  let db = BearDb::new()?;
5
6  // Example 1: Using typed API
7  println!("=== Typed API Examples ===\n");
8
9  let tags = db.tags()?;
10  println!("Total tags: {}\n", tags.count());
11
12  // Using the new NotesQuery API - much more readable!
13  db.notes(NotesQuery::default())?
14    .into_iter()
15    .for_each(|note| {
16      println!("Note: {:?}", note.title());
17      db.note_links(note.id())
18        .unwrap()
19        .into_iter()
20        .for_each(|link| println!("  Linked: {:?}", link.title()));
21
22      let note_tags = db.note_tags(note.id()).unwrap();
23      println!("  Tags: {:?}\n", tags.names(&note_tags));
24    });
25
26  // Example 2: Using generic SQL query API with DataFrames
27  println!("\n=== Generic SQL Query API Examples ===\n");
28
29  // Simple query
30  println!("Top 5 most recent notes:");
31  let df = db
32    .query("SELECT title, created FROM notes WHERE is_trashed = 0 ORDER BY created DESC LIMIT 5")?;
33  println!("{}\n", df);
34
35  // Join query
36  println!("Notes with their tags:");
37  let df = db.query(
38    r"
39    SELECT n.title, t.name as tag_name
40    FROM notes n
41    JOIN note_tags nt ON n.id = nt.note_id
42    JOIN tags t ON nt.tag_id = t.id
43    WHERE n.is_trashed = 0
44    ORDER BY n.modified DESC
45    LIMIT 10
46  ",
47  )?;
48  println!("{}\n", df);
49
50  // Aggregation query
51  println!("Tag usage statistics:");
52  let df = db.query(
53    r"
54    SELECT t.name, COUNT(*) as note_count
55    FROM tags t
56    JOIN note_tags nt ON t.id = nt.tag_id
57    GROUP BY t.id, t.name
58    ORDER BY note_count DESC
59    LIMIT 10
60  ",
61  )?;
62  println!("{}\n", df);
63
64  Ok(())
65}
Source

pub fn note(&self, id: &NoteId) -> Result<Option<Note>, BearError>

Retrieves a specific note by its ID.

Returns None if no note with the given ID exists.

§Examples
let db = BearDb::new()?;

// Look up a note by its UUID
let note_id = NoteId::new("ABC123-DEF456-...".to_string());
if let Some(note) = db.note(&note_id)? {
    println!("Found note: {}", note.title());
} else {
    println!("Note not found");
}
Source

pub fn notes(&self, query: NotesQuery) -> Result<Vec<Note>, BearError>

Retrieves notes from Bear, ordered by most recently modified.

§Examples
let db = BearDb::new()?;

// Get 10 most recent notes (default)
let notes = db.notes(NotesQuery::default())?;

// Get 20 most recent notes
let notes = db.notes(NotesQuery::new().limit(20))?;

// Get all notes including trashed and archived
let notes = db.notes(NotesQuery::new().no_limit().include_all())?;
Examples found in repository?
examples/query_demo.rs (line 13)
3fn main() -> Result<(), BearError> {
4  let db = BearDb::new()?;
5
6  // Example 1: Using typed API
7  println!("=== Typed API Examples ===\n");
8
9  let tags = db.tags()?;
10  println!("Total tags: {}\n", tags.count());
11
12  // Using the new NotesQuery API - much more readable!
13  db.notes(NotesQuery::default())?
14    .into_iter()
15    .for_each(|note| {
16      println!("Note: {:?}", note.title());
17      db.note_links(note.id())
18        .unwrap()
19        .into_iter()
20        .for_each(|link| println!("  Linked: {:?}", link.title()));
21
22      let note_tags = db.note_tags(note.id()).unwrap();
23      println!("  Tags: {:?}\n", tags.names(&note_tags));
24    });
25
26  // Example 2: Using generic SQL query API with DataFrames
27  println!("\n=== Generic SQL Query API Examples ===\n");
28
29  // Simple query
30  println!("Top 5 most recent notes:");
31  let df = db
32    .query("SELECT title, created FROM notes WHERE is_trashed = 0 ORDER BY created DESC LIMIT 5")?;
33  println!("{}\n", df);
34
35  // Join query
36  println!("Notes with their tags:");
37  let df = db.query(
38    r"
39    SELECT n.title, t.name as tag_name
40    FROM notes n
41    JOIN note_tags nt ON n.id = nt.note_id
42    JOIN tags t ON nt.tag_id = t.id
43    WHERE n.is_trashed = 0
44    ORDER BY n.modified DESC
45    LIMIT 10
46  ",
47  )?;
48  println!("{}\n", df);
49
50  // Aggregation query
51  println!("Tag usage statistics:");
52  let df = db.query(
53    r"
54    SELECT t.name, COUNT(*) as note_count
55    FROM tags t
56    JOIN note_tags nt ON t.id = nt.tag_id
57    GROUP BY t.id, t.name
58    ORDER BY note_count DESC
59    LIMIT 10
60  ",
61  )?;
62  println!("{}\n", df);
63
64  Ok(())
65}
Source

pub fn search(&self, search: SearchQuery) -> Result<Vec<Note>, BearError>

Searches notes by title and/or content.

Use SearchQuery to configure search options including which fields to search, sort order, limits, and inclusion of trashed/archived notes.

§Examples
let db = BearDb::new()?;

// Simple search in both title and content
let notes = db.search(SearchQuery::new("rust"))?;

// Search only in titles, sorted alphabetically
let notes = db.search(
    SearchQuery::new("project")
        .title_only()
        .sort_by(SortOn::Title.asc())
)?;

// Case-sensitive search in content with custom limit
let notes = db.search(
    SearchQuery::new("TODO")
        .content_only()
        .case_sensitive()
        .limit(100)
)?;

Retrieves all notes linked from the specified note

Examples found in repository?
examples/query_demo.rs (line 17)
3fn main() -> Result<(), BearError> {
4  let db = BearDb::new()?;
5
6  // Example 1: Using typed API
7  println!("=== Typed API Examples ===\n");
8
9  let tags = db.tags()?;
10  println!("Total tags: {}\n", tags.count());
11
12  // Using the new NotesQuery API - much more readable!
13  db.notes(NotesQuery::default())?
14    .into_iter()
15    .for_each(|note| {
16      println!("Note: {:?}", note.title());
17      db.note_links(note.id())
18        .unwrap()
19        .into_iter()
20        .for_each(|link| println!("  Linked: {:?}", link.title()));
21
22      let note_tags = db.note_tags(note.id()).unwrap();
23      println!("  Tags: {:?}\n", tags.names(&note_tags));
24    });
25
26  // Example 2: Using generic SQL query API with DataFrames
27  println!("\n=== Generic SQL Query API Examples ===\n");
28
29  // Simple query
30  println!("Top 5 most recent notes:");
31  let df = db
32    .query("SELECT title, created FROM notes WHERE is_trashed = 0 ORDER BY created DESC LIMIT 5")?;
33  println!("{}\n", df);
34
35  // Join query
36  println!("Notes with their tags:");
37  let df = db.query(
38    r"
39    SELECT n.title, t.name as tag_name
40    FROM notes n
41    JOIN note_tags nt ON n.id = nt.note_id
42    JOIN tags t ON nt.tag_id = t.id
43    WHERE n.is_trashed = 0
44    ORDER BY n.modified DESC
45    LIMIT 10
46  ",
47  )?;
48  println!("{}\n", df);
49
50  // Aggregation query
51  println!("Tag usage statistics:");
52  let df = db.query(
53    r"
54    SELECT t.name, COUNT(*) as note_count
55    FROM tags t
56    JOIN note_tags nt ON t.id = nt.tag_id
57    GROUP BY t.id, t.name
58    ORDER BY note_count DESC
59    LIMIT 10
60  ",
61  )?;
62  println!("{}\n", df);
63
64  Ok(())
65}
Source

pub fn note_tags(&self, from: &NoteId) -> Result<HashSet<TagId>, BearError>

Retrieves all tag IDs associated with the specified note

Examples found in repository?
examples/query_demo.rs (line 22)
3fn main() -> Result<(), BearError> {
4  let db = BearDb::new()?;
5
6  // Example 1: Using typed API
7  println!("=== Typed API Examples ===\n");
8
9  let tags = db.tags()?;
10  println!("Total tags: {}\n", tags.count());
11
12  // Using the new NotesQuery API - much more readable!
13  db.notes(NotesQuery::default())?
14    .into_iter()
15    .for_each(|note| {
16      println!("Note: {:?}", note.title());
17      db.note_links(note.id())
18        .unwrap()
19        .into_iter()
20        .for_each(|link| println!("  Linked: {:?}", link.title()));
21
22      let note_tags = db.note_tags(note.id()).unwrap();
23      println!("  Tags: {:?}\n", tags.names(&note_tags));
24    });
25
26  // Example 2: Using generic SQL query API with DataFrames
27  println!("\n=== Generic SQL Query API Examples ===\n");
28
29  // Simple query
30  println!("Top 5 most recent notes:");
31  let df = db
32    .query("SELECT title, created FROM notes WHERE is_trashed = 0 ORDER BY created DESC LIMIT 5")?;
33  println!("{}\n", df);
34
35  // Join query
36  println!("Notes with their tags:");
37  let df = db.query(
38    r"
39    SELECT n.title, t.name as tag_name
40    FROM notes n
41    JOIN note_tags nt ON n.id = nt.note_id
42    JOIN tags t ON nt.tag_id = t.id
43    WHERE n.is_trashed = 0
44    ORDER BY n.modified DESC
45    LIMIT 10
46  ",
47  )?;
48  println!("{}\n", df);
49
50  // Aggregation query
51  println!("Tag usage statistics:");
52  let df = db.query(
53    r"
54    SELECT t.name, COUNT(*) as note_count
55    FROM tags t
56    JOIN note_tags nt ON t.id = nt.tag_id
57    GROUP BY t.id, t.name
58    ORDER BY note_count DESC
59    LIMIT 10
60  ",
61  )?;
62  println!("{}\n", df);
63
64  Ok(())
65}
Source

pub fn query(&self, sql: &str) -> Result<DataFrame, BearError>

Execute a generic SQL SELECT query and return results as a Polars DataFrame.

The query automatically has the normalizing CTEs prepended, so you can query against clean table names: notes, tags, note_tags, note_links.

§Safety

This method trusts the read-only connection flags to prevent writes. Only SELECT queries should be used, though this is not enforced by the library.

§Examples
let db = BearDb::new()?;

// Query normalized tables
let df = db.query("SELECT title, modified FROM notes LIMIT 5")?;

// Join tables
let df = db.query(r"
  SELECT n.title, t.name as tag_name
  FROM notes n
  JOIN note_tags nt ON n.id = nt.note_id
  JOIN tags t ON nt.tag_id = t.id
  WHERE n.is_trashed = 0
  LIMIT 10
")?;

println!("{}", df);
Examples found in repository?
examples/query_demo.rs (line 32)
3fn main() -> Result<(), BearError> {
4  let db = BearDb::new()?;
5
6  // Example 1: Using typed API
7  println!("=== Typed API Examples ===\n");
8
9  let tags = db.tags()?;
10  println!("Total tags: {}\n", tags.count());
11
12  // Using the new NotesQuery API - much more readable!
13  db.notes(NotesQuery::default())?
14    .into_iter()
15    .for_each(|note| {
16      println!("Note: {:?}", note.title());
17      db.note_links(note.id())
18        .unwrap()
19        .into_iter()
20        .for_each(|link| println!("  Linked: {:?}", link.title()));
21
22      let note_tags = db.note_tags(note.id()).unwrap();
23      println!("  Tags: {:?}\n", tags.names(&note_tags));
24    });
25
26  // Example 2: Using generic SQL query API with DataFrames
27  println!("\n=== Generic SQL Query API Examples ===\n");
28
29  // Simple query
30  println!("Top 5 most recent notes:");
31  let df = db
32    .query("SELECT title, created FROM notes WHERE is_trashed = 0 ORDER BY created DESC LIMIT 5")?;
33  println!("{}\n", df);
34
35  // Join query
36  println!("Notes with their tags:");
37  let df = db.query(
38    r"
39    SELECT n.title, t.name as tag_name
40    FROM notes n
41    JOIN note_tags nt ON n.id = nt.note_id
42    JOIN tags t ON nt.tag_id = t.id
43    WHERE n.is_trashed = 0
44    ORDER BY n.modified DESC
45    LIMIT 10
46  ",
47  )?;
48  println!("{}\n", df);
49
50  // Aggregation query
51  println!("Tag usage statistics:");
52  let df = db.query(
53    r"
54    SELECT t.name, COUNT(*) as note_count
55    FROM tags t
56    JOIN note_tags nt ON t.id = nt.tag_id
57    GROUP BY t.id, t.name
58    ORDER BY note_count DESC
59    LIMIT 10
60  ",
61  )?;
62  println!("{}\n", df);
63
64  Ok(())
65}
More examples
Hide additional examples
examples/null_analysis.rs (line 14)
7fn main() -> Result<(), bear_query::BearError> {
8  // Connect to Bear's database
9  let db = BearDb::new()?;
10
11  println!("=== Bear Database NULL Value Analysis ===\n");
12
13  // Query for notes with NULL titles
14  let null_titles_df = db.query("SELECT COUNT(*) as count FROM notes WHERE title IS NULL")?;
15  let null_titles_count = null_titles_df.column("count")?.i64()?.get(0).unwrap();
16
17  println!("Notes with NULL titles: {}", null_titles_count);
18
19  // Query for notes with NULL content
20  let null_content_df = db.query("SELECT COUNT(*) as count FROM notes WHERE content IS NULL")?;
21  let null_content_count = null_content_df.column("count")?.i64()?.get(0).unwrap();
22
23  println!("Notes with NULL content: {}", null_content_count);
24
25  // Query for notes with NULL id (UUID)
26  let null_id_df = db.query("SELECT COUNT(*) as count FROM notes WHERE id IS NULL")?;
27  let null_id_count = null_id_df.column("count")?.i64()?.get(0).unwrap();
28
29  println!("Notes with NULL id: {}", null_id_count);
30
31  // Get total note count for comparison
32  let total_df = db.query("SELECT COUNT(*) as count FROM notes")?;
33  let total_count = total_df.column("count")?.i64()?.get(0).unwrap();
34
35  println!("\nTotal notes in database: {}", total_count);
36
37  // Show percentages
38  if total_count > 0 {
39    println!("\n=== Percentages ===");
40    println!(
41      "NULL titles: {:.2}%",
42      (null_titles_count as f64 / total_count as f64) * 100.0
43    );
44    println!(
45      "NULL content: {:.2}%",
46      (null_content_count as f64 / total_count as f64) * 100.0
47    );
48    println!(
49      "NULL id: {:.2}%",
50      (null_id_count as f64 / total_count as f64) * 100.0
51    );
52  }
53
54  // Show some examples of notes with NULL titles (if any exist)
55  if null_titles_count > 0 {
56    println!("\n=== Sample Notes with NULL Titles ===");
57    let sample_df = db.query("SELECT id, content FROM notes WHERE title IS NULL LIMIT 5")?;
58
59    println!("{}", sample_df);
60  }
61
62  // Show some examples of notes with NULL content (if any exist)
63  if null_content_count > 0 {
64    println!("\n=== Sample Notes with NULL Content ===");
65    let sample_df = db.query("SELECT id, title FROM notes WHERE content IS NULL LIMIT 5")?;
66
67    println!("{}", sample_df);
68  }
69
70  // More detailed analysis: notes with multiple NULL fields
71  println!("\n=== Notes with Multiple NULL Fields ===");
72  let multiple_nulls_df = db.query(
73    r"
74        SELECT
75            COUNT(*) as count,
76            CASE
77                WHEN title IS NULL AND content IS NULL THEN 'Both title and content'
78                WHEN title IS NULL AND id IS NULL THEN 'Both title and id'
79                WHEN content IS NULL AND id IS NULL THEN 'Both content and id'
80                ELSE 'Other combination'
81            END as null_combination
82        FROM notes
83        WHERE (title IS NULL OR content IS NULL OR id IS NULL)
84        GROUP BY null_combination
85        ",
86  )?;
87
88  if multiple_nulls_df.height() > 0 {
89    println!("{}", multiple_nulls_df);
90  } else {
91    println!("No notes with multiple NULL fields found.");
92  }
93
94  // Analysis by note status (trashed, archived, etc.)
95  println!("\n=== NULL Values by Note Status ===");
96  let by_status_df = db.query(
97    r"
98        SELECT
99            CASE
100                WHEN is_trashed = 1 THEN 'Trashed'
101                WHEN is_archived = 1 THEN 'Archived'
102                ELSE 'Active'
103            END as status,
104            COUNT(*) as total_notes,
105            SUM(CASE WHEN title IS NULL THEN 1 ELSE 0 END) as null_titles,
106            SUM(CASE WHEN content IS NULL THEN 1 ELSE 0 END) as null_content,
107            SUM(CASE WHEN id IS NULL THEN 1 ELSE 0 END) as null_id
108        FROM notes
109        GROUP BY status
110        ORDER BY total_notes DESC
111        ",
112  )?;
113
114  println!("{}", by_status_df);
115
116  Ok(())
117}

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
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
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
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.
Source§

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

Source§

fn vzip(self) -> V