gorust 0.1.8

Go-style concurrency in Rust - bringing Go-style concurrency patterns to Rust with familiar primitives like goroutines and channels
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>gorust - Go 风格并发,Rust 极致性能</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,600;14..32,700&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #0a0f1e 0%, #0f172a 100%);
            color: #e2e8f0;
            line-height: 1.6;
        }

        .container {
            max-width: 1280px;
            margin: 0 auto;
            padding: 0 2rem;
        }

        /* 导航栏 */
        .navbar {
            padding: 1.5rem 0;
            border-bottom: 1px solid rgba(100, 116, 139, 0.2);
            backdrop-filter: blur(10px);
            position: sticky;
            top: 0;
            background: rgba(15, 23, 42, 0.8);
            z-index: 10;
        }

        .nav-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 1.5rem;
            font-weight: 700;
            background: linear-gradient(135deg, #60a5fa, #a78bfa);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }

        .nav-links {
            display: flex;
            gap: 2rem;
            align-items: center;
        }

        .nav-links a {
            color: #cbd5e1;
            text-decoration: none;
            font-weight: 500;
            transition: color 0.2s;
        }

        .nav-links a:hover {
            color: #60a5fa;
        }

        .github-link {
            background: #334155;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            text-decoration: none;
            color: #f1f5f9;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .github-link:hover {
            background: #475569;
            transform: translateY(-1px);
        }

        /* 按钮 */
        .btn {
            display: inline-block;
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            font-weight: 600;
            text-decoration: none;
            transition: all 0.2s ease;
            cursor: pointer;
        }

        .btn-primary {
            background: linear-gradient(135deg, #3b82f6, #8b5cf6);
            color: white;
            border: none;
            box-shadow: 0 4px 14px 0 rgba(59,130,246,0.4);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px 0 rgba(59,130,246,0.6);
        }

        .btn-outline {
            border: 1px solid #60a5fa;
            color: #60a5fa;
            background: transparent;
        }

        .btn-outline:hover {
            background: rgba(96, 165, 250, 0.1);
            transform: translateY(-1px);
        }

        /* Hero 区域 */
        .hero {
            padding: 5rem 0;
            text-align: center;
        }

        .hero h1 {
            font-size: 3.5rem;
            font-weight: 800;
            background: linear-gradient(135deg, #fff, #94a3b8);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            margin-bottom: 1rem;
        }

        .hero .tagline {
            font-size: 1.25rem;
            color: #94a3b8;
            margin-bottom: 2rem;
            max-width: 700px;
            margin-left: auto;
            margin-right: auto;
        }

        .badge {
            background: rgba(96, 165, 250, 0.2);
            border: 1px solid #3b82f6;
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.85rem;
            display: inline-block;
            margin-bottom: 1rem;
        }

        /* 性能卡片 */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 1.5rem;
            margin: 4rem 0;
        }

        .stat-card {
            background: rgba(30, 41, 59, 0.6);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(100, 116, 139, 0.3);
            border-radius: 16px;
            padding: 1.5rem;
            text-align: center;
            transition: transform 0.2s;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            border-color: #60a5fa;
        }

        .stat-number {
            font-size: 2.5rem;
            font-weight: 800;
            color: #60a5fa;
            margin-bottom: 0.5rem;
        }

        .stat-label {
            font-size: 0.9rem;
            color: #94a3b8;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .stat-unit {
            font-size: 1rem;
            color: #64748b;
        }

        /* 特性网格 */
        .features {
            margin: 5rem 0;
        }

        .section-title {
            font-size: 2rem;
            font-weight: 700;
            text-align: center;
            margin-bottom: 3rem;
            color: #f1f5f9;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
        }

        .feature-card {
            background: rgba(30, 41, 59, 0.4);
            border-radius: 16px;
            padding: 1.5rem;
            border: 1px solid rgba(100, 116, 139, 0.2);
            transition: all 0.2s;
        }

        .feature-card:hover {
            border-color: #60a5fa;
            transform: translateY(-3px);
        }

        .feature-icon {
            font-size: 2rem;
            margin-bottom: 1rem;
        }

        .feature-title {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
            color: #f1f5f9;
        }

        /* 代码示例 */
        .code-section {
            background: #0f172a;
            border-radius: 16px;
            padding: 2rem;
            margin: 3rem 0;
            border: 1px solid #334155;
        }

        .code-title {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 1rem;
            color: #cbd5e1;
        }

        .example-tabs {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
            flex-wrap: wrap;
        }

        .tab-btn {
            padding: 0.5rem 1rem;
            background: #1e293b;
            color: #cbd5e1;
            border: 1px solid #334155;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s;
            font-weight: 500;
        }

        .tab-btn.active {
            background: linear-gradient(135deg, #3b82f6, #8b5cf6);
            border-color: transparent;
            color: white;
        }

        .tab-btn:hover:not(.active) {
            background: #334155;
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        pre {
            background: #1e293b;
            padding: 1.5rem;
            border-radius: 8px;
            overflow-x: auto;
            font-size: 0.9rem;
            line-height: 1.6;
        }

        code {
            font-family: 'Monaco', 'Consolas', monospace;
            color: #a5f3fc;
        }

        .code-block {
            background: #1e293b;
            border-radius: 8px;
            padding: 1.5rem;
            overflow-x: auto;
            font-size: 0.9rem;
            line-height: 1.6;
            border: 1px solid #334155;
        }

        .code-block code {
            color: #a5f3fc;
        }

        .code-block .comment { color: #64748b; }
        .code-block .keyword { color: #c084fc; }
        .code-block .string { color: #fbbf24; }
        .code-block .function { color: #60a5fa; }
        .code-block .type { color: #34d399; }
        .code-block .macro { color: #fb923c; }
        .code-block .number { color: #f472b6; }

        /* 架构部分 */
        .architecture {
            margin: 5rem 0;
        }

        .arch-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin-top: 2rem;
        }

        .arch-item {
            background: rgba(30, 41, 59, 0.4);
            border-radius: 16px;
            padding: 1.5rem;
            border: 1px solid rgba(100, 116, 139, 0.2);
            border-left: 4px solid #3b82f6;
        }

        .arch-item h4 {
            color: #60a5fa;
            margin-bottom: 0.5rem;
            font-size: 1.1rem;
        }

        .arch-item p {
            color: #94a3b8;
            font-size: 0.9rem;
        }

        /* API 表格 */
        .comparison-table {
            width: 100%;
            border-collapse: collapse;
            margin: 2rem 0;
            background: rgba(30, 41, 59, 0.4);
            border-radius: 12px;
            overflow: hidden;
        }

        .comparison-table th,
        .comparison-table td {
            padding: 1rem;
            text-align: left;
            border-bottom: 1px solid #334155;
        }

        .comparison-table th {
            background: #1e293b;
            font-weight: 600;
            color: #cbd5e1;
        }

        .comparison-table tr:last-child td {
            border-bottom: none;
        }

        .comparison-table code {
            background: rgba(96, 165, 250, 0.2);
            padding: 0.2rem 0.5rem;
            border-radius: 4px;
            font-size: 0.85rem;
        }

        .highlight {
            color: #60a5fa;
            font-weight: 600;
        }

        /* 快速开始 */
        .quick-start {
            margin: 3rem 0;
        }

        /* footer */
        .footer {
            text-align: center;
            padding: 3rem 0;
            border-top: 1px solid #334155;
            margin-top: 4rem;
            color: #64748b;
        }

        .footer a {
            color: #60a5fa;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }

        @media (max-width: 768px) {
            .hero h1 { font-size: 2rem; }
            .stat-number { font-size: 1.8rem; }
            .nav-links { display: none; }
        }

        /* 滚动动画 */
        .fade-in {
            opacity: 0;
            transform: translateY(20px);
            transition: opacity 0.6s, transform 0.6s;
        }

        .fade-in.visible {
            opacity: 1;
            transform: translateY(0);
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar">
        <div class="container nav-content">
            <div class="logo">gorust</div>
            <div class="nav-links">
                <a href="#features">功能</a>
                <a href="#examples">示例</a>
                <a href="#architecture">架构</a>
                <a href="#api">API</a>
                <a href="https://github.com/WLmutou/gorust" class="github-link" target="_blank">GitHub ↗</a>
            </div>
        </div>
    </nav>

    <main class="container">
        <!-- Hero -->
        <section class="hero">
            <div class="badge">✨ v0.1.8 - 实验性发布</div>
            <h1>gorust: <br> Go 风格并发,Rust 极致性能</h1>
            <p class="tagline">
                一个轻量级、高性能的并发运行时,将 Go 语言的并发模型与 Rust 的零成本抽象完美结合。
                提供熟悉的 goroutines、channels 和 select 原语,让 Rust 并发编程更简单。
            </p>
            <div style="display: flex; gap: 1rem; justify-content: center; margin-top: 2rem;">
                <a href="#quick-start" class="btn btn-primary">快速开始</a>
                <a href="https://github.com/WLmutou/gorust" class="btn btn-outline">GitHub 仓库</a>
            </div>
        </section>

        <!-- 核心指标 -->
        <section>
            <div class="stats-grid">
                <div class="stat-card fade-in">
                    <div class="stat-number">9+</div>
                    <div class="stat-label">核心模块</div>
                    <div class="stat-unit">channel, scheduler, timer...</div>
                </div>
                <div class="stat-card fade-in">
                    <div class="stat-number">15+</div>
                    <div class="stat-label">示例程序</div>
                    <div class="stat-unit">examples/</div>
                </div>
                <div class="stat-card fade-in">
                    <div class="stat-number">M:N</div>
                    <div class="stat-label">调度模型</div>
                    <div class="stat-unit">工作窃取算法</div>
                </div>
                <div class="stat-card fade-in">
                    <div class="stat-number">~3MB</div>
                    <div class="stat-label">内存占用</div>
                    <div class="stat-unit">基础运行时</div>
                </div>
            </div>
        </section>

        <!-- 核心特性 -->
        <section class="features" id="features">
            <h2 class="section-title">为什么选择 gorust?</h2>
            <div class="features-grid">
                <div class="feature-card fade-in">
                    <div class="feature-icon">🚀</div>
                    <div class="feature-title">Goroutines</div>
                    <div>轻量级协程,类似 Go 的 goroutine。使用 <code>go()</code> 函数轻松创建并发任务,自动管理生命周期。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">📡</div>
                    <div class="feature-title">Channels</div>
                    <div>支持有缓冲和无缓冲通道,实现 goroutine 间的通信。提供 <code>send()</code><code>recv()</code> 方法。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">🎯</div>
                    <div class="feature-title">Select 宏</div>
                    <div>类似 Go 的 select 语句,支持多路复用通道操作。使用 <code>select!</code> 宏或函数式 API。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">⏱️</div>
                    <div class="feature-title">定时器</div>
                    <div>提供 <code>sleep()</code><code>sleep_ms()</code> 函数,支持协程级别的睡眠,不阻塞其他协程。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">🔒</div>
                    <div class="feature-title">同步原语</div>
                    <div>WaitGroup、Mutex、RWMutex、AtomicCounter、Once 等完整的同步工具集合。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">🌐</div>
                    <div class="feature-title">网络轮询器</div>
                    <div>基于 mio 的事件驱动网络轮询器,支持异步 I/O 操作,高效处理网络连接。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">📊</div>
                    <div class="feature-title">工作窃取调度器</div>
                    <div>M:N 调度模型,支持工作窃取算法,充分利用多核 CPU,自动负载均衡。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">🔧</div>
                    <div class="feature-title">过程宏</div>
                    <div><code>#[runtime]</code><code>select!</code><code>make_chan!</code> 等宏,提供类 Go 语法。</div>
                </div>
                <div class="feature-card fade-in">
                    <div class="feature-icon">🛡️</div>
                    <div class="feature-title">Ctrl-C 信号处理</div>
                    <div>内置信号处理,优雅关闭运行时,确保所有 goroutine 安全退出。</div>
                </div>
            </div>
        </section>

        <!-- 代码示例 -->
        <section class="code-section" id="examples">
            <div class="code-title">📄 代码示例</div>
            <div class="example-tabs">
                <button class="tab-btn active" data-tab="basic">基础示例</button>
                <button class="tab-btn" data-tab="channel">通道通信</button>
                <button class="tab-btn" data-tab="select">Select</button>
                <button class="tab-btn" data-tab="sync">同步原语</button>
            </div>

            <div class="tab-content active" id="basic">
                <pre><code>use gorust::{go, runtime, Runtime, yield_now, sleep};

#[runtime]
fn main() {
    // 创建 goroutine
    go(|| {
        println!("Hello from goroutine!");
    });

    // 带参数的 goroutine
    for i in 0..5 {
        go(move || {
            println!("Goroutine {} is running", i);
            yield_now();
            println!("Goroutine {} done", i);
        });
    }

    println!("Active goroutines: {}", Runtime::active_goroutines());
}</code></pre>
            </div>

            <div class="tab-content" id="channel">
                <pre><code>use gorust::{go, runtime, make_chan};

#[runtime]
fn main() {
    // 创建无缓冲通道
    let ch = make_chan!(i32);
    
    // 发送端
    let ch_snd = ch.clone();
    go(move || {
        ch_snd.send(42).unwrap();
        println!("Value sent!");
    });

    // 接收端
    let ch_rcv = ch.clone();
    go(move || {
        let value = ch_rcv.recv().unwrap();
        println!("Received: {}", value);
    });

    // 有缓冲通道
    let ch2 = make_chan!(String, 10);
    ch2.send("Hello".to_string()).unwrap();
    let received = ch2.recv().unwrap();
}</code></pre>
            </div>

            <div class="tab-content" id="select">
                <pre><code>use gorust::{go, runtime, make_chan, select, sleep};
use std::time::Duration;

#[runtime]
fn main() {
    let ch1 = make_chan!(i32);
    let ch2 = make_chan!(String);

    // 使用 select! 宏
    select! {
        recv(ch1) -> msg => {
            println!("Got from ch1: {:?}", msg);
        }
        recv(ch2) -> msg => {
            println!("Got from ch2: {:?}", msg);
        }
        default => {
            println!("No channel ready");
        }
    }

    // 使用函数式 API
    let result = select_builder()
        .recv(&ch1, |msg| println!("Got: {:?}", msg))
        .timeout(Duration::from_secs(2), || println!("Timeout!"))
        .execute();
}</code></pre>
            </div>

            <div class="tab-content" id="sync">
                <pre><code>use gorust::{go, runtime, sleep};
use gorust::sync::{WaitGroup, AtomicCounter};
use std::time::Duration;

#[runtime]
fn main() {
    // WaitGroup 示例
    let wg = WaitGroup::new();
    for i in 0..3 {
        wg.add(1);
        let wg_clone = wg.clone();
        go(move || {
            println!("Task {} starting", i);
            sleep(Duration::from_secs(i));
            println!("Task {} finished", i);
            wg_clone.done();
        });
    }
    wg.wait();

    // AtomicCounter 示例
    let counter = AtomicCounter::new();
    for _ in 0..100 {
        let c = counter.clone();
        go(move || {
            c.increment();
        });
    }
    println!("Count: {}", counter.get());
}</code></pre>
            </div>
        </section>

        <!-- 架构 -->
        <section class="architecture" id="architecture">
            <h2 class="section-title">架构设计</h2>
            <div class="arch-grid">
                <div class="arch-item fade-in">
                    <h4>调度器 (Scheduler)</h4>
                    <p>M:N 调度模型,多个工作线程(Processor)各自维护本地队列,支持工作窃取算法实现负载均衡。</p>
                </div>
                <div class="arch-item fade-in">
                    <h4>协程 (Goroutine)</h4>
                    <p>轻量级用户态协程,初始栈仅 2KB,自动栈增长。协程由调度器管理,非操作系统线程。</p>
                </div>
                <div class="arch-item fade-in">
                    <h4>通道 (Channel)</h4>
                    <p>支持有缓冲和无缓冲通道,内部使用环形队列实现,提供阻塞和非阻塞的 send/recv 操作。</p>
                </div>
                <div class="arch-item fade-in">
                    <h4>定时器 (Timer)</h4>
                    <p>分层定时器实现,基于最小堆管理超时事件,支持协程级别的 sleep 而不阻塞其他协程。</p>
                </div>
                <div class="arch-item fade-in">
                    <h4>网络轮询器 (Netpoller)</h4>
                    <p>基于 mio 的事件驱动 I/O 多路复用,支持 TCP/UDP 异步操作,高效处理网络连接。</p>
                </div>
                <div class="arch-item fade-in">
                    <h4>同步原语 (Sync)</h4>
                    <p>提供 WaitGroup、Mutex、RWMutex、Pool、Context 等 Go 风格的同步工具。</p>
                </div>
            </div>
        </section>

        <!-- API 参考 -->
        <section id="api">
            <h2 class="section-title">核心 API</h2>
            <table class="comparison-table">
                <thead>
                    <tr>
                        <th>API</th>
                        <th>类型</th>
                        <th>描述</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>go(fn)</code></td>
                        <td>函数</td>
                        <td>创建新的 goroutine</td>
                    </tr>
                    <tr>
                        <td><code>#[runtime]</code></td>
                        <td></td>
                        <td>初始化运行时并管理生命周期</td>
                    </tr>
                    <tr>
                        <td><code>make_chan!(T)</code></td>
                        <td></td>
                        <td>创建无缓冲通道</td>
                    </tr>
                    <tr>
                        <td><code>make_chan!(T, cap)</code></td>
                        <td></td>
                        <td>创建有缓冲通道</td>
                    </tr>
                    <tr>
                        <td><code>select! { ... }</code></td>
                        <td></td>
                        <td>多路复用通道操作</td>
                    </tr>
                    <tr>
                        <td><code>sleep(duration)</code></td>
                        <td>函数</td>
                        <td>协程级睡眠</td>
                    </tr>
                    <tr>
                        <td><code>yield_now()</code></td>
                        <td>函数</td>
                        <td>主动让出 CPU</td>
                    </tr>
                    <tr>
                        <td><code>Runtime::wait_for_all()</code></td>
                        <td>函数</td>
                        <td>等待所有协程完成</td>
                    </tr>
                </tbody>
            </table>
        </section>

        <!-- 快速开始 -->
        <section class="code-section quick-start" id="quick-start">
            <div class="code-title">🚀 快速开始</div>
            <pre><code># 添加依赖
[dependencies]
gorust = { git = "https://github.com/WLmutou/gorust.git" }

# 创建一个简单的并发程序
cargo new my_gorust_app
cd my_gorust_app</code></pre>
            <div style="margin-top: 1rem;">
                <a href="https://github.com/WLmutou/gorust" class="btn btn-primary">GitHub 仓库</a>
                <a href="https://docs.rs/gorust" class="btn btn-outline" style="margin-left: 1rem;">阅读文档 →</a>
            </div>
        </section>

        <div class="footer">
            <p>gorust - 开源 · 高性能 · 用 Rust 实现 Go 的并发梦想</p>
            <p style="margin-top: 0.5rem;">
                <a href="https://github.com/WLmutou/gorust">GitHub</a> | 
                <a href="https://crates.io/crates/gorust">crates.io</a> | 
                <a href="https://docs.rs/gorust">文档</a>
            </p>
        </div>
    </main>

    <script>
        // Tab 切换
        document.querySelectorAll('.tab-btn').forEach(btn => {
            btn.addEventListener('click', () => {
                const tabId = btn.dataset.tab;
                document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
                document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
                btn.classList.add('active');
                document.getElementById(tabId).classList.add('active');
            });
        });

        // 滚动动画
        const observer = new IntersectionObserver((entries) => {
            entries.forEach(entry => {
                if (entry.isIntersecting) {
                    entry.target.classList.add('visible');
                }
            });
        }, { threshold: 0.1 });

        document.querySelectorAll('.fade-in').forEach(el => observer.observe(el));
    </script>
</body>
</html>