repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/controllers/auth.rs | src/tests_cfg/controllers/auth.rs | use crate::controller::Routes;
#[must_use]
pub fn routes() -> Routes {
Routes::new()
}
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/controllers/mod.rs | src/tests_cfg/controllers/mod.rs | pub mod auth;
pub mod home;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/testing/db.rs | src/testing/db.rs | use crate::{
app::{AppContext, Hooks},
db, hash, Error, Result,
};
use sqlx::{Pool, Postgres};
use std::future::Future;
use std::path::PathBuf;
use std::pin::Pin;
use tree_fs::TreeBuilder;
/// Seeds data into the database.
///
///
/// # Errors
/// When seed fails
///
/// # Example
///
/// The provided example ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/testing/prelude.rs | src/testing/prelude.rs | #[cfg(feature = "with-db")]
pub use crate::testing::db::*;
pub use crate::testing::{redaction::*, request::*, selector::*};
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/testing/mod.rs | src/testing/mod.rs | #[cfg(feature = "with-db")]
pub mod db;
pub mod prelude;
pub mod redaction;
pub mod request;
pub mod selector;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/testing/request.rs | src/testing/request.rs | use std::net::SocketAddr;
use axum_test::{TestServer, TestServerConfig};
use tokio::net::TcpListener;
#[cfg(feature = "with-db")]
use crate::Error;
use crate::{
app::{AppContext, Hooks},
boot::{self, BootResult},
config::Server,
environment::Environment,
Result,
};
#[cfg(feature = "with-db")]
use... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/testing/selector.rs | src/testing/selector.rs | use scraper::{Html, Selector};
/// Asserts that an element matching the given CSS selector exists in the
/// provided HTML.
///
/// # Example
///
/// ```rust
/// use loco_rs::testing::prelude::*;
///
/// let html = r#"
/// <html>
/// <body>
/// <div class="some-class">Some content here</div>
/// ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/testing/redaction.rs | src/testing/redaction.rs | use std::sync::OnceLock;
static CLEANUP_USER_MODEL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
static CLEANUP_DATE: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
static CLEANUP_MODEL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
static CLEANUP_MAIL: OnceLock<Vec<(... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/mod.rs | tests/mod.rs | mod build_scripts;
mod controller;
mod infra_cfg;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/middlewares.rs | tests/controller/middlewares.rs | use std::{collections::BTreeMap, path::PathBuf};
use axum::http::StatusCode;
use insta::assert_debug_snapshot;
use loco_rs::{controller::middleware, prelude::*, tests_cfg};
use rstest::rstest;
use crate::infra_cfg;
macro_rules! configure_insta {
($($expr:expr),*) => {
let mut settings = insta::Settings::... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/into_response.rs | tests/controller/into_response.rs | use loco_rs::{controller, prelude::*, tests_cfg};
use serde::{Deserialize, Serialize};
use crate::infra_cfg;
#[tokio::test]
async fn not_found() {
let ctx = tests_cfg::app::get_app_context().await;
#[allow(clippy::items_after_statements)]
async fn action() -> Result<Response> {
controller::not_fo... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/mod.rs | tests/controller/mod.rs | mod extractor;
mod into_response;
mod middlewares;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/extractor/shared_store.rs | tests/controller/extractor/shared_store.rs | use axum::extract::State;
use loco_rs::{controller::format, prelude::*, tests_cfg};
use rstest::rstest;
use serde::{Deserialize, Serialize};
use crate::infra_cfg;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
struct MySharedData {
message: String,
}
struct MySharedDataWithoutClone {
message: Str... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/extractor/mod.rs | tests/controller/extractor/mod.rs | mod auth;
mod shared_store;
mod validate;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/extractor/validate.rs | tests/controller/extractor/validate.rs | use loco_rs::{prelude::*, tests_cfg};
use serde::{Deserialize, Serialize};
use validator::Validate;
use crate::infra_cfg;
#[derive(Debug, Deserialize, Serialize, Validate)]
pub struct Data {
#[validate(length(min = 5, message = "message_str"))]
pub name: String,
#[validate(email)]
pub email: String,
}... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/extractor/auth/jwt.rs | tests/controller/extractor/auth/jwt.rs | use loco_rs::{controller::extractor::auth, prelude::*, tests_cfg};
use serde::{Deserialize, Serialize};
use crate::infra_cfg;
#[derive(Debug, Deserialize, Serialize)]
pub struct TestResponse {
pub pid: String,
}
// Test handler for JWT extractor
async fn jwt_handler(auth: auth::JWT) -> Result<Response> {
for... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | true |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/extractor/auth/jwt_with_user.rs | tests/controller/extractor/auth/jwt_with_user.rs | use loco_rs::{controller::extractor::auth, prelude::*, tests_cfg};
use serde::{Deserialize, Serialize};
use loco_rs::model::{Authenticable, ModelError};
use crate::infra_cfg;
#[derive(Debug, Deserialize, Serialize)]
pub struct TestUserResponse {
pub pid: String,
pub user_id: i32,
pub user_email: String,
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/extractor/auth/mod.rs | tests/controller/extractor/auth/mod.rs | mod jwt;
#[cfg(feature = "with-db")]
mod jwt_with_user;
#[cfg(feature = "with-db")]
mod api_token;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/controller/extractor/auth/api_token.rs | tests/controller/extractor/auth/api_token.rs | use loco_rs::{controller::extractor::auth, prelude::*, tests_cfg};
use serde::{Deserialize, Serialize};
use loco_rs::model::{Authenticable, ModelError};
use crate::infra_cfg;
#[derive(Debug, Deserialize, Serialize)]
pub struct TestUserResponse {
pub pid: String,
pub user_id: i32,
pub user_email: String,
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/build_scripts/mod.rs | tests/build_scripts/mod.rs | mod embedded_assets;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/build_scripts/embedded_assets.rs | tests/build_scripts/embedded_assets.rs | use insta::{assert_debug_snapshot, assert_snapshot};
use std::collections::HashMap;
use std::path::Path; // For creating regex filters
// Import only the essential functions from build/embedded_assets.rs
// Use a module declaration with the `#[path]` attribute to specify the file path
#[path = "../../build/embedded_as... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/infra_cfg/mod.rs | tests/infra_cfg/mod.rs | pub mod server;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/tests/infra_cfg/server.rs | tests/infra_cfg/server.rs | //! # Server Infrastructure Utilities for Loco Framework Testing
//!
//! This module provides utility functions to test a server using the Loco
//! framework. It includes helper functions to start the server from different
//! configurations, such as from boot parameters, application context, or a
//! custom route. The... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/build/embedded_assets.rs | build/embedded_assets.rs | use std::collections::{HashMap, HashSet};
use std::{
env,
fs::{self, File},
io::{self, Write},
path::{Path, PathBuf},
};
pub fn build_static_assets(out_dir: &Path) {
// Determine the application root directory using Cargo environment variables
let Some(app_dir) = find_app_directory(out_dir) els... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/infer.rs | loco-gen/src/infer.rs | use cruet::{case::snake::to_snake_case, Inflector};
use crate::{Error, Result};
#[derive(Debug, PartialEq, Eq)]
pub enum MigrationType {
CreateTable { table: String },
AddColumns { table: String },
RemoveColumns { table: String },
AddReference { table: String },
CreateJoinTable { table_a: String, ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/tera_ext.rs | loco-gen/src/tera_ext.rs | use std::collections::HashMap;
use tera::{Tera, Value};
#[must_use]
pub fn new() -> Tera {
let mut tera = Tera::default();
tera.register_function("render_form_field", FormField);
tera.register_function("render_view_field", ViewField);
tera
}
const DEFAULT_INPUT_CLASS: &str = "flex h-9 w-full rounded-... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/lib.rs | loco-gen/src/lib.rs | // this is because not using with-db renders some of the structs below unused
// TODO: should be more properly aligned with extracting out the db-related gen
// code and then feature toggling it
#![allow(dead_code)]
pub use rrgen::{GenResult, RRgen};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
m... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/template.rs | loco-gen/src/template.rs | use std::path::{Path, PathBuf};
use include_dir::{include_dir, Dir, DirEntry, File};
use crate::{Error, Result};
static TEMPLATES: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src/templates");
pub const DEFAULT_LOCAL_TEMPLATE: &str = ".loco-templates";
/// Returns a list of paths that should be ignored during file c... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/controller.rs | loco-gen/src/controller.rs | use super::{AppInfo, GenerateResults, Result};
use crate as gen;
use rrgen::RRgen;
use serde_json::json;
use std::path::Path;
pub fn generate(
rrgen: &RRgen,
name: &str,
actions: &[String],
kind: &gen::ScaffoldKind,
appinfo: &AppInfo,
) -> Result<GenerateResults> {
let vars = json!({"name": nam... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/model.rs | loco-gen/src/model.rs | use std::{collections::HashMap, env::current_dir, path::Path};
use chrono::Utc;
use duct::cmd;
use heck::ToUpperCamelCase;
use rrgen::RRgen;
use serde_json::json;
use crate::{
get_mappings, infer::parse_field_type, render_template, AppInfo, Error, GenerateResults, Result,
};
/// skipping some fields from the gen... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/testutil.rs | loco-gen/src/testutil.rs | //
// generator test toolkit
// to be extracted to a library later.
//
use std::{
env,
error::Error,
fs,
path::{Path, PathBuf},
process::Command,
};
use regex::Regex;
// Define the custom struct to encapsulate file content
pub struct FileContent {
content: String,
}
impl FileContent {
// ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/migration.rs | loco-gen/src/migration.rs | use std::path::Path;
use chrono::Utc;
use rrgen::RRgen;
use serde_json::json;
use crate::{
infer, model::get_columns_and_references, render_template, AppInfo, GenerateResults, Result,
};
/// skipping some fields from the generated models.
/// For example, the `created_at` and `updated_at` fields are automaticall... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/src/scaffold.rs | loco-gen/src/scaffold.rs | use std::path::Path;
use rrgen::RRgen;
use serde_json::json;
use crate::{
get_mappings, infer::parse_field_type, model, render_template, AppInfo, Error, GenerateResults,
Result, ScaffoldKind,
};
pub fn generate(
rrgen: &RRgen,
name: &str,
with_tz: bool,
fields: &[(String, String)],
kind: ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/db.rs | loco-gen/tests/db.rs | use duct::cmd;
use insta::assert_snapshot;
use loco_gen::get_mappings;
use rstest::rstest;
use serial_test::serial;
use std::{collections::HashMap, env::current_dir, fs::read_to_string};
#[rstest]
#[serial]
fn test_migrations_flow(#[values("postgres", "sqlite")] db_kind: &str) {
if db_kind == "postgres" && std::en... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/mod.rs | loco-gen/tests/mod.rs | mod templates;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/mailer.rs | loco-gen/tests/templates/mailer.rs | use insta::assert_snapshot;
use loco_gen::{collect_messages, generate, AppInfo, Component};
use rrgen::RRgen;
use std::fs;
#[test]
fn can_generate() {
let mut settings = insta::Settings::clone_current();
settings.set_prepend_module_to_snapshot(false);
settings.set_snapshot_suffix("mailer");
let _guard ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/deployment.rs | loco-gen/tests/templates/deployment.rs | use insta::assert_snapshot;
use loco_gen::{collect_messages, generate, AppInfo, Component, DeploymentKind};
use rrgen::RRgen;
use std::{fs, path::PathBuf};
#[rstest::rstest]
fn can_generate_docker(
#[values(vec![], vec![std::path::PathBuf::from("404.html"), PathBuf::from("asset")])]
copy_paths: Vec<PathBuf>,
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/controller.rs | loco-gen/tests/templates/controller.rs | use super::utils::APP_ROUTS;
use insta::assert_snapshot;
use loco_gen::{collect_messages, generate, AppInfo, Component, ScaffoldKind};
use rrgen::RRgen;
use rstest::rstest;
use std::fs;
#[rstest]
#[case(ScaffoldKind::Api)]
#[case(ScaffoldKind::Html)]
#[case(ScaffoldKind::Htmx)]
#[test]
fn can_generate(#[case] kind: Sc... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/worker.rs | loco-gen/tests/templates/worker.rs | use super::utils::APP_WORKER;
use insta::assert_snapshot;
use loco_gen::{collect_messages, generate, AppInfo, Component};
use rrgen::RRgen;
use std::fs;
macro_rules! configure_insta {
() => {
let mut settings = insta::Settings::clone_current();
settings.set_prepend_module_to_snapshot(false);
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/utils.rs | loco-gen/tests/templates/utils.rs | use chrono::{Duration, Utc};
use std::path::{Path, PathBuf};
pub const MIGRATION_SRC_LIB: &str = r"
#![allow(elided_lifetimes_in_paths)]
#![allow(clippy::wildcard_imports)]
pub use sea_orm_migration::prelude::*;
mod m20220101_000001_users;
pub struct Migrator;
#[async_trait::async_trait]
impl MigratorTrait for Migra... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/model.rs | loco-gen/tests/templates/model.rs | use super::utils::{guess_file_by_time, MIGRATION_SRC_LIB};
use insta::{assert_snapshot, with_settings};
use loco_gen::{collect_messages, generate, AppInfo, Component};
use rrgen::RRgen;
use std::fs;
macro_rules! configure_insta {
() => {
let mut settings = insta::Settings::clone_current();
settings... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/mod.rs | loco-gen/tests/templates/mod.rs | mod controller;
mod deployment;
mod mailer;
#[cfg(feature = "with-db")]
mod migration;
#[cfg(feature = "with-db")]
mod model;
#[cfg(feature = "with-db")]
mod scaffold;
mod scheduler;
mod task;
mod utils;
mod worker;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/task.rs | loco-gen/tests/templates/task.rs | use super::utils::APP_TASK;
use insta::assert_snapshot;
use loco_gen::{collect_messages, generate, AppInfo, Component};
use rrgen::RRgen;
use std::fs;
macro_rules! configure_insta {
() => {
let mut settings = insta::Settings::clone_current();
settings.set_prepend_module_to_snapshot(false);
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/migration.rs | loco-gen/tests/templates/migration.rs | use super::utils::{guess_file_by_time, MIGRATION_SRC_LIB};
use insta::{assert_snapshot, with_settings};
use loco_gen::{collect_messages, generate, AppInfo, Component};
use rrgen::RRgen;
use rstest::rstest;
use std::fs;
#[rstest]
#[case("create_table", Component::Migration {
name: "CreateMovies".to_string(),
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/scheduler.rs | loco-gen/tests/templates/scheduler.rs | use insta::assert_snapshot;
use loco_gen::{collect_messages, generate, AppInfo, Component};
use rrgen::RRgen;
use std::fs;
macro_rules! configure_insta {
($($expr:expr),*) => {
let mut settings = insta::Settings::clone_current();
settings.set_prepend_module_to_snapshot(false);
settings.set_... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-gen/tests/templates/scaffold.rs | loco-gen/tests/templates/scaffold.rs | use super::utils::{guess_file_by_time, APP_ROUTS, MIGRATION_SRC_LIB};
use insta::{assert_snapshot, with_settings};
use loco_gen::{collect_messages, generate, tera_ext, AppInfo, Component, ScaffoldKind};
use rrgen::RRgen;
use rstest::rstest;
use std::fs;
#[rstest]
#[case(ScaffoldKind::Api)]
#[case(ScaffoldKind::Html)]
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/errors.rs | xtask/src/errors.rs | use std::path::PathBuf;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("{0}")]
Message(String),
#[error(
"could not bump package {} version. not found in path {:?}",
package,
path
)]
BumpVersion { path: PathBuf, package: String },
#[error(transparent)]
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/ci.rs | xtask/src/ci.rs | use std::{
path::{Path, PathBuf},
process::Output,
};
use duct::cmd;
use crate::{errors::Result, utils};
const FMT_TEST: [&str; 3] = ["test", "--all-features", "--all"];
const FMT_ARGS: [&str; 2] = ["fmt", "--all"];
const FMT_CLIPPY: [&str; 8] = [
"clippy",
"--",
"-W",
"clippy::pedantic",
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/lib.rs | xtask/src/lib.rs | use std::process::exit;
pub mod bump_version;
pub mod ci;
pub mod errors;
pub mod out;
pub mod prompt;
pub mod utils;
pub mod versions;
#[derive(Debug)]
pub struct CmdExit {
pub code: i32,
pub message: Option<String>,
}
impl CmdExit {
#[must_use]
pub fn error_with_message(message: &str) -> Self {
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/out.rs | xtask/src/out.rs | use tabled::settings::Style;
use crate::ci::RunResults;
pub fn print_ci_results(result: &Vec<RunResults>) -> String {
let mut builder = tabled::builder::Builder::default();
builder.push_record(vec!["path", "fmt", "clippy", "test"]);
for ci in result {
builder.push_record(vec![
format... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/utils.rs | xtask/src/utils.rs | use std::{
fs,
path::{Path, PathBuf},
};
pub const FOLDER_EXAMPLES: &str = "examples";
pub const FOLDER_STARTERS: &str = "starters";
pub const FOLDER_LOCO_CLI: &str = "loco-cli";
/// return a lost of cargo project in the given path
///
/// # Errors
/// when could not read the given dir path
pub fn get_cargo_f... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/prompt.rs | xtask/src/prompt.rs | /// Prompt confirmation message
///
/// # Errors
/// return an error when could prompt the message or could not parse the input
pub fn confirmation(message: &str) -> eyre::Result<bool> {
let question = requestty::Question::confirm("confirm")
.message(message)
.build();
let res = requestty::prom... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/bump_version.rs | xtask/src/bump_version.rs | use std::{
fs,
io::{Read, Write},
path::{Path, PathBuf},
sync::OnceLock,
};
use cargo_metadata::semver::Version;
use colored::Colorize;
use regex::Regex;
use crate::{
ci,
errors::{Error, Result},
out, utils,
};
static REPLACE_LOCO_LIB_VERSION_: OnceLock<Regex> = OnceLock::new();
static RE... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/versions.rs | xtask/src/versions.rs | use std::{
env::{self, current_dir},
path::Path,
};
use duct::cmd;
use regex::Regex;
use crate::{
ci::{cargo_clippy, cargo_fmt},
errors::Result,
};
fn bump_version_in_file(
file_path: &str,
version_regex: &str,
replacement_version: &str,
once: bool,
) {
let path = Path::new(file_p... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/xtask/src/bin/main.rs | xtask/src/bin/main.rs | use std::env;
use cargo_metadata::{semver::Version, MetadataCommand, Package};
use clap::{
ArgAction::{SetFalse, SetTrue},
Parser, Subcommand,
};
use xtask::versions;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
#[command(subcomm... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-cli/src/lib.rs | loco-cli/src/lib.rs | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false | |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/loco-cli/src/bin/main.rs | loco-cli/src/bin/main.rs | fn main() {
println!("==============================================");
println!(" ⚠️ DEPRECATION NOTICE: `loco-cli`");
println!("==============================================");
println!();
println!("🌟 `loco-cli` has been replaced with `loco`, a more powerful and flexible CLI for creating Loco ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
pretzelhammer/rust-blog | https://github.com/pretzelhammer/rust-blog/blob/3d33acbb0dc199a073802d9f19ee7da4ee1bcac9/assets/main.rs | assets/main.rs | fn main() {
println!("hopefully github detects this file and categorizes my repo as a Rust repo");
}
| rust | Apache-2.0 | 3d33acbb0dc199a073802d9f19ee7da4ee1bcac9 | 2026-01-04T15:47:59.090729Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/lib.rs | src/lib.rs | use leptos::prelude::*;
use leptos_meta::*;
use leptos_router::{components::*, path};
// Modules
mod components;
mod pages;
// Top-Level pages
use crate::pages::home::Home;
/// An app router which renders the homepage and handles 404's
#[component]
pub fn App() -> impl IntoView {
// Provides context that manages... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/main.rs | src/main.rs | use leptos::prelude::*;
use ccfddl::App;
fn main() {
// set up logging
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| {
view! { <App /> }
})
}
| rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/pages/home.rs | src/pages/home.rs | use leptos::prelude::*;
use crate::components::header::Header;
use crate::components::showtable::ShowTable;
use thaw::*;
/// Default Home Page
#[component]
pub fn Home() -> impl IntoView {
// theme
let theme = RwSignal::new(Theme::light());
theme.update(|theme| {
theme.color.set_color_compound_br... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/pages/mod.rs | src/pages/mod.rs | pub mod home;
| rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/countdown.rs | src/components/countdown.rs | use leptos::prelude::*;
use std::time::Duration;
/// Countdown timer component.
#[component]
pub fn CountDown(
/// The remaining time in seconds.
remain: u64,
) -> impl IntoView {
let remaining_time = RwSignal::new(remain / 1000);
use_interval(1000, move || {
remaining_time.update(|r| {
... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/timezone.rs | src/components/timezone.rs | use chrono_tz::Tz;
use std::str::FromStr;
// Get browser timezone name (e.g., "Asia/Shanghai", "America/New_York")
#[cfg(target_arch = "wasm32")]
pub fn get_timezone_name() -> Option<String> {
web_sys::js_sys::eval("Intl.DateTimeFormat().resolvedOptions().timeZone")
.ok()
.and_then(|v| v.as_string(... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/calendar_popover.rs | src/components/calendar_popover.rs | use leptos::prelude::*;
use leptos::*;
use thaw::*;
use chrono::{DateTime, Utc};
#[component]
pub fn CalendarPopover(
google_calendar_url: Option<String>,
icloud_calendar_url: Option<String>,
is_mobile: RwSignal<bool>
) -> impl IntoView {
let show_popover = RwSignal::new(false);
view! {
<d... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/conf.rs | src/components/conf.rs | use serde::{Deserialize, Serialize};
use chrono::prelude::*;
#[derive(Debug, Serialize, Deserialize)]
pub struct Conference {
pub title: String,
pub description: String,
pub sub: String,
pub rank: Rank,
pub dblp: String,
pub confs: Vec<ConferenceYear>,
}
#[derive(Debug, Serialize, Deserialize)... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/showtable.rs | src/components/showtable.rs | use crate::components::checkbox_button::*;
use crate::components::conf::ConfItem;
use crate::components::conf::*;
use crate::components::countdown::CountDown;
use crate::components::timeline::*;
use crate::components::timezone::*;
use crate::components::calendar_popover::*;
use chrono::{DateTime, FixedOffset, Utc};
use... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | true |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/header.rs | src/components/header.rs | use leptos::prelude::*;
use serde::{Deserialize, Serialize};
use wasm_bindgen_futures::spawn_local;
use web_sys::{console, js_sys, window};
use crate::components::gitbutton::GitButton;
#[derive(Debug, Deserialize, Serialize, Clone)]
struct CommitData {
commit: CommitInfo,
}
#[derive(Debug, Deserialize, Serialize... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/mod.rs | src/components/mod.rs | pub mod gitbutton;
pub mod header;
pub mod timeline;
pub mod showtable;
pub mod countdown;
pub mod timezone;
pub mod checkbox_button;
pub mod calendar_popover;
pub mod conf;
| rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/timeline.rs | src/components/timeline.rs | use leptos::*;
use leptos::prelude::*;
use chrono::{prelude::*, Duration};
use crate::components::conf::TimePoint;
use web_sys::js_sys;
#[component]
pub fn TimeLine(time_points: Vec<TimePoint>) -> impl IntoView {
let (sel_time, set_sel_time) = signal(String::new());
let (start_date, set_start_date) = signal(0.... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/checkbox_button.rs | src/components/checkbox_button.rs | use leptos::*;
use leptos::prelude::*;
use std::collections::HashSet;
#[component]
pub fn CheckboxButton(
label: String,
value: String,
rank_list: RwSignal<HashSet<String>>,
#[prop(optional)] is_first: bool,
#[prop(optional)] is_last: bool,
) -> impl IntoView {
let value_clone = value.clone();
... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
ccfddl/ccf-deadlines | https://github.com/ccfddl/ccf-deadlines/blob/21fec70ecd69bb21b9b6cd470c308b12fe370d98/src/components/gitbutton.rs | src/components/gitbutton.rs | use leptos::prelude::*;
#[component]
pub fn GitButton() -> impl IntoView {
view! {
<iframe
src="https://ghbtns.com/github-btn.html?user=ccfddl&repo=ccf-deadlines&type=star&count=true&size=large"
width="170"
height="30"
title="GitHub"
class="github... | rust | MIT | 21fec70ecd69bb21b9b6cd470c308b12fe370d98 | 2026-01-04T15:47:31.300157Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/bench/src/lib.rs | bench/src/lib.rs | use neon::prelude::*;
#[neon::export]
fn export_noop() {}
fn manual_noop(mut cx: FunctionContext) -> JsResult<JsUndefined> {
Ok(cx.undefined())
}
fn hello(mut cx: FunctionContext) -> JsResult<JsString> {
Ok(cx.string("hello node"))
}
fn call_callback_with_call(mut cx: FunctionContext) -> JsResult<JsValue> {... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/lib.rs | test/napi/src/lib.rs | use neon::{object::Class, prelude::*};
use once_cell::sync::OnceCell;
use tokio::runtime::Runtime;
use crate::js::{
arrays::*, boxed::*, coercions::*, date::*, errors::*, functions::*, numbers::*, objects::*,
strings::*, threads::*, typedarrays::*, types::*,
};
mod js {
pub mod arrays;
pub mod bigint;... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/errors.rs | test/napi/src/js/errors.rs | use neon::prelude::*;
pub fn new_error(mut cx: FunctionContext) -> JsResult<JsError> {
let msg = cx.argument::<JsString>(0)?.value(&mut cx);
cx.error(msg)
}
pub fn new_type_error(mut cx: FunctionContext) -> JsResult<JsError> {
let msg = cx.argument::<JsString>(0)?.value(&mut cx);
cx.type_error(msg)
... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/date.rs | test/napi/src/js/date.rs | use neon::{prelude::*, types::JsDate};
pub fn create_date(mut cx: FunctionContext) -> JsResult<JsDate> {
let date = JsDate::new_lossy(&mut cx, 31415);
Ok(date)
}
pub fn create_date_from_value(mut cx: FunctionContext) -> JsResult<JsDate> {
let time = cx.argument::<JsNumber>(0)?.value(&mut cx);
let date... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/objects.rs | test/napi/src/js/objects.rs | use std::borrow::Cow;
use neon::{prelude::*, types::buffer::TypedArray};
pub fn return_js_global_object(mut cx: FunctionContext) -> JsResult<JsObject> {
Ok(cx.global_object())
}
pub fn return_js_object(mut cx: FunctionContext) -> JsResult<JsObject> {
Ok(cx.empty_object())
}
pub fn return_js_object_with_mixe... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/futures.rs | test/napi/src/js/futures.rs | use std::future::Future;
use neon::{
prelude::*,
types::{
buffer::TypedArray,
extract::{self, Error, Json, TryIntoJs},
},
};
use crate::runtime;
// Accepts two functions that take no parameters and return numbers.
// Resolves with the sum of the two numbers.
// Purpose: Test the `Future` ... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/arrays.rs | test/napi/src/js/arrays.rs | use neon::prelude::*;
pub fn return_js_array(mut cx: FunctionContext) -> JsResult<JsArray> {
Ok(cx.empty_array())
}
pub fn return_js_array_with_number(mut cx: FunctionContext) -> JsResult<JsArray> {
let array: Handle<JsArray> = JsArray::new(&mut cx, 1);
let n = cx.number(9000.0);
array.set(&mut cx, 0,... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/bigint.rs | test/napi/src/js/bigint.rs | /// Tests for [`JsBigInt`]. All unit tests are prefixed with `test_` and exported by
/// [`bigint_suite`].
use std::{any, cmp::PartialEq, fmt, panic, str::FromStr};
use neon::{
prelude::*,
types::{
bigint::{RangeError, Sign},
JsBigInt,
},
};
use num_bigint_dig::BigInt;
// Helper that conv... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/container.rs | test/napi/src/js/container.rs | use neon::prelude::*;
use std::{
cell::{Ref, RefCell, RefMut},
rc::Rc,
sync::Arc,
};
#[neon::export]
fn create_string_ref_cell(s: String) -> RefCell<String> {
RefCell::new(s)
}
#[neon::export]
fn read_string_ref_cell(s: &RefCell<String>) -> String {
s.borrow().clone()
}
#[neon::export]
fn write_... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/class.rs | test/napi/src/js/class.rs | use std::{collections::HashMap, future::Future};
use neon::{event::Channel, prelude::*, types::extract::Json};
#[neon::export]
fn wrap_string(cx: &mut Cx, o: Handle<JsObject>, s: String) -> NeonResult<()> {
neon::macro_internal::object::wrap(cx, o, s)?.or_throw(cx)
}
#[neon::export]
fn unwrap_string(cx: &mut Cx,... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/functions.rs | test/napi/src/js/functions.rs | use neon::{prelude::*, types::extract};
fn add1(mut cx: FunctionContext) -> JsResult<JsNumber> {
let x = cx.argument::<JsNumber>(0)?.value(&mut cx);
Ok(cx.number(x + 1.0))
}
pub fn return_js_function(mut cx: FunctionContext) -> JsResult<JsFunction> {
JsFunction::new(&mut cx, add1)
}
pub fn call_js_functi... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/types.rs | test/napi/src/js/types.rs | use neon::prelude::*;
pub fn is_string(mut cx: FunctionContext) -> JsResult<JsBoolean> {
let val: Handle<JsValue> = cx.argument(0)?;
let result = val.is_a::<JsString, _>(&mut cx);
Ok(cx.boolean(result))
}
pub fn is_array(mut cx: FunctionContext) -> JsResult<JsBoolean> {
let val: Handle<JsValue> = cx.a... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/threads.rs | test/napi/src/js/threads.rs | use std::{cell::RefCell, sync::Arc, time::Duration};
use neon::{
prelude::*,
types::{buffer::TypedArray, extract::Error},
};
pub fn useless_root(mut cx: FunctionContext) -> JsResult<JsObject> {
let object = cx.argument::<JsObject>(0)?;
let root = object.root(&mut cx);
let object = root.into_inner(... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/numbers.rs | test/napi/src/js/numbers.rs | use neon::prelude::*;
pub fn return_js_number(mut cx: FunctionContext) -> JsResult<JsNumber> {
Ok(cx.number(9000_f64))
}
pub fn return_large_js_number(mut cx: FunctionContext) -> JsResult<JsNumber> {
Ok(cx.number(4294967296_f64))
}
pub fn return_negative_js_number(mut cx: FunctionContext) -> JsResult<JsNumbe... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/strings.rs | test/napi/src/js/strings.rs | use neon::{prelude::*, reflect::eval};
pub fn return_js_string(mut cx: FunctionContext) -> JsResult<JsString> {
Ok(cx.string("hello node"))
}
pub fn return_js_string_utf16(mut cx: FunctionContext) -> JsResult<JsTypedArray<u16>> {
let raw = "hello 🥹".encode_utf16().collect::<Vec<_>>();
JsTypedArray::from_... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/boxed.rs | test/napi/src/js/boxed.rs | use std::cell::RefCell;
use neon::{prelude::*, types::extract::Boxed};
pub struct Person {
name: String,
}
impl Finalize for Person {}
impl Person {
fn new(name: impl ToString) -> Self {
Self {
name: name.to_string(),
}
}
fn greet(&self) -> String {
format!("Hell... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/extract.rs | test/napi/src/js/extract.rs | use either::Either;
use neon::{prelude::*, types::extract::*};
pub fn extract_values(mut cx: FunctionContext) -> JsResult<JsArray> {
#[allow(clippy::type_complexity)]
let (
boolean,
number,
unit,
string,
Date(date),
value,
array_buf,
buf,
... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/export.rs | test/napi/src/js/export.rs | use std::sync::LazyLock;
use neon::{
prelude::*,
types::extract::{Boxed, Error},
};
#[neon::export]
const NUMBER: u8 = 42;
#[neon::export]
static STRING: &str = "Hello, World!";
#[neon::export]
static LAZY_LOCK_HELLO: LazyLock<String> = LazyLock::new(|| String::from("Hello, Neon!"));
#[neon::export(name = ... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/coercions.rs | test/napi/src/js/coercions.rs | use neon::prelude::*;
pub fn to_string(mut cx: FunctionContext) -> JsResult<JsString> {
let arg: Handle<JsValue> = cx.argument(0)?;
arg.to_string(&mut cx)
}
| rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/workers.rs | test/napi/src/js/workers.rs | use std::{convert::TryFrom, sync::Mutex, thread, time::Duration};
use once_cell::sync::{Lazy, OnceCell};
use neon::prelude::*;
use neon::thread::LocalKey;
pub fn get_and_replace(mut cx: FunctionContext) -> JsResult<JsValue> {
static OBJECT: Lazy<Mutex<Option<Root<JsObject>>>> = Lazy::new(Default::default);
... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/napi/src/js/typedarrays.rs | test/napi/src/js/typedarrays.rs | use neon::{
prelude::*,
types::buffer::{Binary, BorrowError, TypedArray},
};
pub fn return_array_buffer(mut cx: FunctionContext) -> JsResult<JsArrayBuffer> {
let b: Handle<JsArrayBuffer> = cx.array_buffer(16)?;
Ok(b)
}
pub fn return_array_buffer_from_slice(mut cx: FunctionContext) -> JsResult<JsArrayB... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/electron/src/lib.rs | test/electron/src/lib.rs | use neon::prelude::*;
fn hello(mut cx: FunctionContext) -> JsResult<JsString> {
Ok(cx.string("Hello, World!"))
}
#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
cx.export_function("hello", hello)?;
Ok(())
}
| rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/ui/src/lib.rs | test/ui/src/lib.rs | #[rustversion::attr(not(stable), ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/fail/*.rs");
t.pass("tests/pass/*.rs");
}
| rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/ui/tests/fail/unnecessary-attribute.rs | test/ui/tests/fail/unnecessary-attribute.rs | #[neon::export(async)]
async fn async_with_async() {}
fn main() {}
| rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/ui/tests/fail/need-borrowed-context.rs | test/ui/tests/fail/need-borrowed-context.rs | #[neon::export]
fn owned_cx(_cx: Cx) {}
#[neon::export]
fn owned_function_cx(_cx: FunctionContext) {}
#[neon::export]
fn ref_cx(_cx: &Cx) {}
#[neon::export]
fn ref_function_cx(_cx: &FunctionContext) {}
#[neon::export(context)]
fn forced_cx(_cx: String) {}
#[neon::export(context)]
fn forced_ref_cx(_cx: &String) {}
... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/ui/tests/fail/class-async-borrowed-channel.rs | test/ui/tests/fail/class-async-borrowed-channel.rs | use neon::prelude::*;
struct Example;
#[neon::class]
impl Example {
#[neon(async)]
fn method(&self, _ch: &Channel) {}
}
fn main() {}
| rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/ui/tests/fail/wrong-context.rs | test/ui/tests/fail/wrong-context.rs | #[neon::export]
fn sync_channel(_ch: Channel) {}
#[neon::export]
fn sync_borrow_channel(_ch: &mut Channel) {}
#[neon::export(async)]
fn async_channel(_ch: Channel) {}
#[neon::export(async)]
fn async_borrow_channel(_ch: &mut Channel) {}
#[neon::export]
async fn async_cx(_cx: Cx) {}
#[neon::export]
async fn async_fu... | rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
neon-bindings/neon | https://github.com/neon-bindings/neon/blob/22098e4d9f1c4b29447671298bc839476b6826dc/test/ui/tests/fail/class-invalid-property-name.rs | test/ui/tests/fail/class-invalid-property-name.rs | struct Example;
#[neon::class]
impl Example {
#[neon(name = "123invalid")]
const VALUE: i32 = 42;
}
fn main() {}
| rust | Apache-2.0 | 22098e4d9f1c4b29447671298bc839476b6826dc | 2026-01-04T15:47:42.000902Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.