Skip to content

Commit 5ac02a3

Browse files
committed
docs: update Rust traits implementation article
- Add beginner tag to the article - Update article's modified time - Update related tags in other pages
1 parent d40a62a commit 5ac02a3

File tree

9 files changed

+211
-17
lines changed

9 files changed

+211
-17
lines changed

how-to-check-traits-implemented-for-a-struct-or-enum/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<meta property="og:type" content="article">
1414
<meta property="article:section" content="posts">
1515
<meta property="article:published_time" content="2025-01-04T20:15:03+08:00">
16-
<meta property="article:modified_time" content="2025-01-05T22:48:40+08:00">
16+
<meta property="article:modified_time" content="2025-01-04T20:15:03+08:00">
1717
<meta property="article:tag" content="Rust">
18+
<meta property="article:tag" content="Beginner">
1819
<meta property="og:image" content="https://pain.devxfamily.com/logo.png">
1920

2021
<meta name="twitter:card" content="summary_large_image">
@@ -37,8 +38,8 @@
3738
"mainEntityOfPage": {
3839
"@type": "WebPage",
3940
"@id": "https:\/\/pain.devxfamily.com\/how-to-check-traits-implemented-for-a-struct-or-enum\/"
40-
},"image": ["https:\/\/pain.devxfamily.com\/images\/Apple-Devices-Preview.png"],"genre": "posts","keywords": "rust","wordcount": 544 ,
41-
"url": "https:\/\/pain.devxfamily.com\/how-to-check-traits-implemented-for-a-struct-or-enum\/","datePublished": "2025-01-04T20:15:03+08:00","dateModified": "2025-01-05T22:48:40+08:00","license": "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.","publisher": {
41+
},"image": ["https:\/\/pain.devxfamily.com\/images\/Apple-Devices-Preview.png"],"genre": "posts","keywords": "rust, beginner","wordcount": 544 ,
42+
"url": "https:\/\/pain.devxfamily.com\/how-to-check-traits-implemented-for-a-struct-or-enum\/","datePublished": "2025-01-04T20:15:03+08:00","dateModified": "2025-01-04T20:15:03+08:00","license": "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.","publisher": {
4243
"@type": "Organization",
4344
"name": "xxxx","logo": {
4445
"@type": "ImageObject",
@@ -339,21 +340,20 @@ <h2 id="references">References</h2>
339340
<div class="post-info">
340341
<div class="post-info-line">
341342
<div class="post-info-mod">
342-
<span>Updated on 2025-01-05&nbsp;<a class="git-hash" href="https://github.com/devxpain/devxpain.github.io.git/commit/4fc70a4efc152d0e1b84fa15240fe54ce880a7be" target="_blank" title="commit by devxpain(170700110&#43;devxpain@users.noreply.github.com) 4fc70a4efc152d0e1b84fa15240fe54ce880a7be: docs: update Rust traits implementation article">
343-
<i class="fas fa-hashtag fa-fw" aria-hidden="true"></i>4fc70a4</a></span>
343+
<span>Updated on 2025-01-04</span>
344344
</div></div>
345345
<div class="post-info-line">
346346
<div class="post-info-md"><span>
347347
<a class="link-to-markdown" href="/how-to-check-traits-implemented-for-a-struct-or-enum/index.md" target="_blank">Read Markdown</a>
348348
</span></div>
349349
<div class="post-info-share">
350-
<span><a href="javascript:void(0);" title="Share on Twitter" data-sharer="twitter" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum" data-via="devxpain0" data-hashtags="rust"><i class="fab fa-twitter fa-fw" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on Facebook" data-sharer="facebook" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-hashtag="rust"><i class="fab fa-facebook-square fa-fw" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on Hacker News" data-sharer="hackernews" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum"><i class="fab fa-hacker-news fa-fw" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on Line" data-sharer="line" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum"><i data-svg-src="https://cdn.jsdelivr.net/npm/simple-icons@7.3.0/icons/line.svg" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on 微博" data-sharer="weibo" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum"><i class="fab fa-weibo fa-fw" aria-hidden="true"></i></a></span>
350+
<span><a href="javascript:void(0);" title="Share on Twitter" data-sharer="twitter" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum" data-via="devxpain0" data-hashtags="rust,beginner"><i class="fab fa-twitter fa-fw" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on Facebook" data-sharer="facebook" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-hashtag="rust"><i class="fab fa-facebook-square fa-fw" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on Hacker News" data-sharer="hackernews" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum"><i class="fab fa-hacker-news fa-fw" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on Line" data-sharer="line" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum"><i data-svg-src="https://cdn.jsdelivr.net/npm/simple-icons@7.3.0/icons/line.svg" aria-hidden="true"></i></a><a href="javascript:void(0);" title="Share on 微博" data-sharer="weibo" data-url="https://pain.devxfamily.com/how-to-check-traits-implemented-for-a-struct-or-enum/" data-title="Rust Tips: How to Check Traits Implemented for a Struct or Enum"><i class="fab fa-weibo fa-fw" aria-hidden="true"></i></a></span>
351351
</div>
352352
</div>
353353
</div>
354354

355355
<div class="post-info-more">
356-
<section class="post-tags"><i class="fas fa-tags fa-fw" aria-hidden="true"></i>&nbsp;<a href="/tags/rust/">Rust</a></section>
356+
<section class="post-tags"><i class="fas fa-tags fa-fw" aria-hidden="true"></i>&nbsp;<a href="/tags/rust/">Rust</a>,&nbsp;<a href="/tags/beginner/">Beginner</a></section>
357357
<section>
358358
<span><a href="javascript:void(0);" onclick="window.history.back();">Back</a></span>&nbsp;|&nbsp;<span><a href="/">Home</a></span>
359359
</section>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ <h2 id="java-example">Java Example</h2>
160160
</div>
161161
</div><p>In Rust, however, traits implemented by a struct or enum might not be as immediately obvious, since their implementations can be scattered across multiple files.</p></div><div class="post-footer">
162162
<a href="/how-to-check-traits-implemented-for-a-struct-or-enum/">Read More</a><div class="post-tags">
163-
<i class="fas fa-tags fa-fw" aria-hidden="true"></i>&nbsp;<a href="/tags/rust/">Rust</a></div></div>
163+
<i class="fas fa-tags fa-fw" aria-hidden="true"></i>&nbsp;<a href="/tags/rust/">Rust</a>,&nbsp;<a href="/tags/beginner/">Beginner</a></div></div>
164164
</article>
165165
</div></div>
166166
</main><footer class="footer">

index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"categories":null,"content":"Ex-game dev transitioning into web, crypto, and algo trading. Building with Rust 🦀, sharing my journey, growing a community, and actively seeking roles in tech ","date":"2025-01-05","objectID":"/about/:0:0","tags":null,"title":"About","uri":"/about/"},{"categories":["rust"],"content":"When transitioning from OOP languages to Rust, you might notice some differences in how traits (similar to interface in Java) are handled. In OOP, a class often centralizes information about inherited interfaces, making it easy to see at a glance. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:0:0","tags":["rust"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"Java Example // Interfaces.java interface InterfaceA { void methodA(); } interface InterfaceB { void methodB(); } // ConcreteClass.java public class ConcreteClass implements InterfaceA, InterfaceB { @Override public void methodA() { // Implementation for methodA } @Override public void methodB() { // Implementation for methodB } } In Rust, however, traits implemented by a struct or enum might not be as immediately obvious, since their implementations can be scattered across multiple files. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:1:0","tags":["rust"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"Rust Example // interfaces.rs pub trait InterfaceA { fn method_a(\u0026self); } pub trait InterfaceB { fn method_b(\u0026self); } // concrete_struct.rs pub struct ConcreteStruct; impl ConcreteStruct { pub fn new() -\u003e Self { ConcreteStruct } } // impl_a.rs use crate::interfaces::InterfaceA; use crate::concrete_struct::ConcreteStruct; impl InterfaceA for ConcreteStruct { fn method_a(\u0026self) { // Implementation for method_a } } // impl_b.rs use crate::interfaces::InterfaceB; use crate::concrete_struct::ConcreteStruct; impl InterfaceB for ConcreteStruct { fn method_b(\u0026self) { // Implementation for method_b } } Thankfully, rust-analyzer, a powerful tool for Rust developers, bridges this gap and makes exploring trait implementations seamless. In this article, we’ll explore how to leverage rust-analyzer in NeoVim and VSCode to quickly check which traits a Rust struct or enum implements. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:2:0","tags":["rust"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"NeoVim: Leveraging rustaceanvim [^1] If you’re using NeoVim, here’s how you can easily inspect trait implementations: Set Up rustaceanvim: Ensure you have rustaceanvim configured as your Rust development environment. Navigate to the Symbol: Place your cursor over the struct or enum whose trait implementations you want to inspect. Open the Symbol Inspector: Press SHIFT+K twice. This opens the symbol inspector, displaying useful information about the symbol. Find Trait Implementations: Look for the line that says “Go to [x] implementations” (where x represents the number of implementations). Press Enter to open a window showing all the traits implemented by that symbol. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:3:0","tags":["rust"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"VSCode: Simplified with rust-analyzer VSCode users can also take advantage of rust-analyzer for similar functionality. Here’s how: Install rust-analyzer Extension: Make sure you have the rust-analyzer extension installed and enabled in your VSCode setup. Navigate to the Symbol: Click or place your cursor on the struct or enum you’re interested in. Open the Symbol Inspector: Press SHIFT+K once. This opens a detailed view of the symbol, including trait implementations. Explore Implementations: Click on the “[x] implementations” link. A new window will appear, listing all the traits implemented by the symbol. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:4:0","tags":["rust"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"Why This Matters Understanding which traits a struct or enum implements is essential for maintaining and debugging Rust code, especially in larger projects. By integrating rust-analyzer into your workflow, you can overcome Rust’s decentralized trait implementation syntax and make your development process smoother. Whether you’re using NeoVim or VSCode, rust-analyzer empowers you to navigate and understand your codebase with confidence. Try these tips today and experience the productivity boost firsthand! ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:5:0","tags":["rust"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"References [^1] rustaceanvim ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:6:0","tags":["rust"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"}]
1+
[{"categories":null,"content":"Ex-game dev transitioning into web, crypto, and algo trading. Building with Rust 🦀, sharing my journey, growing a community, and actively seeking roles in tech ","date":"2025-01-05","objectID":"/about/:0:0","tags":null,"title":"About","uri":"/about/"},{"categories":["rust"],"content":"When transitioning from OOP languages to Rust, you might notice some differences in how traits (similar to interface in Java) are handled. In OOP, a class often centralizes information about inherited interfaces, making it easy to see at a glance. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:0:0","tags":["rust","beginner"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"Java Example // Interfaces.java interface InterfaceA { void methodA(); } interface InterfaceB { void methodB(); } // ConcreteClass.java public class ConcreteClass implements InterfaceA, InterfaceB { @Override public void methodA() { // Implementation for methodA } @Override public void methodB() { // Implementation for methodB } } In Rust, however, traits implemented by a struct or enum might not be as immediately obvious, since their implementations can be scattered across multiple files. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:1:0","tags":["rust","beginner"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"Rust Example // interfaces.rs pub trait InterfaceA { fn method_a(\u0026self); } pub trait InterfaceB { fn method_b(\u0026self); } // concrete_struct.rs pub struct ConcreteStruct; impl ConcreteStruct { pub fn new() -\u003e Self { ConcreteStruct } } // impl_a.rs use crate::interfaces::InterfaceA; use crate::concrete_struct::ConcreteStruct; impl InterfaceA for ConcreteStruct { fn method_a(\u0026self) { // Implementation for method_a } } // impl_b.rs use crate::interfaces::InterfaceB; use crate::concrete_struct::ConcreteStruct; impl InterfaceB for ConcreteStruct { fn method_b(\u0026self) { // Implementation for method_b } } Thankfully, rust-analyzer, a powerful tool for Rust developers, bridges this gap and makes exploring trait implementations seamless. In this article, we’ll explore how to leverage rust-analyzer in NeoVim and VSCode to quickly check which traits a Rust struct or enum implements. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:2:0","tags":["rust","beginner"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"NeoVim: Leveraging rustaceanvim [^1] If you’re using NeoVim, here’s how you can easily inspect trait implementations: Set Up rustaceanvim: Ensure you have rustaceanvim configured as your Rust development environment. Navigate to the Symbol: Place your cursor over the struct or enum whose trait implementations you want to inspect. Open the Symbol Inspector: Press SHIFT+K twice. This opens the symbol inspector, displaying useful information about the symbol. Find Trait Implementations: Look for the line that says “Go to [x] implementations” (where x represents the number of implementations). Press Enter to open a window showing all the traits implemented by that symbol. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:3:0","tags":["rust","beginner"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"VSCode: Simplified with rust-analyzer VSCode users can also take advantage of rust-analyzer for similar functionality. Here’s how: Install rust-analyzer Extension: Make sure you have the rust-analyzer extension installed and enabled in your VSCode setup. Navigate to the Symbol: Click or place your cursor on the struct or enum you’re interested in. Open the Symbol Inspector: Press SHIFT+K once. This opens a detailed view of the symbol, including trait implementations. Explore Implementations: Click on the “[x] implementations” link. A new window will appear, listing all the traits implemented by the symbol. ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:4:0","tags":["rust","beginner"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"Why This Matters Understanding which traits a struct or enum implements is essential for maintaining and debugging Rust code, especially in larger projects. By integrating rust-analyzer into your workflow, you can overcome Rust’s decentralized trait implementation syntax and make your development process smoother. Whether you’re using NeoVim or VSCode, rust-analyzer empowers you to navigate and understand your codebase with confidence. Try these tips today and experience the productivity boost firsthand! ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:5:0","tags":["rust","beginner"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"},{"categories":["rust"],"content":"References [^1] rustaceanvim ","date":"2025-01-04","objectID":"/how-to-check-traits-implemented-for-a-struct-or-enum/:6:0","tags":["rust","beginner"],"title":"Rust Tips: How to Check Traits Implemented for a Struct or Enum","uri":"/how-to-check-traits-implemented-for-a-struct-or-enum/"}]

0 commit comments

Comments
 (0)