blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
140
path
stringlengths
5
183
src_encoding
stringclasses
6 values
length_bytes
int64
12
5.32M
score
float64
2.52
4.94
int_score
int64
3
5
detected_licenses
listlengths
0
47
license_type
stringclasses
2 values
text
stringlengths
12
5.32M
download_success
bool
1 class
6449e354555f67fe0618a1631f1380b07d6d834b
Rust
chanakyap/solanalotto
/program/src/error.rs
UTF-8
808
2.84375
3
[]
no_license
use thiserror::Error; use solana_program::program_error::ProgramError; #[derive(Error, Debug, Copy, Clone)] pub enum LotteryError { /// Invalid instruction #[error("Invalid Instruction")] InvalidInstruction, /// Not Rent Exempt #[error("Not Rent Exempt")] NotRentExempt, /// Tic...
true
4bceb225400c01b56944549759e8fe933ca3268d
Rust
Shifu-Engineer/whitebox-tools
/src/tools/data_tools/raster_to_vector_polygons.rs
UTF-8
29,045
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/* This tool is part of the WhiteboxTools geospatial analysis library. Authors: Dr. John Lindsay Created: 25/12/2019 Last Modified: 25/12/2019 License: MIT */ use crate::raster::*; use crate::tools::*; use crate::vector::*; use std::env; use std::f64; use std::io::{Error, ErrorKind}; use std::path; /// Converts a ras...
true
0805c8c6a710e0f4a719f9f76b0094cc70f8ef57
Rust
mikrostew/rlox
/src/resolver.rs
UTF-8
10,957
3.3125
3
[]
no_license
use std::collections::HashMap; use std::rc::Rc; use crate::ast::{Expr, Identifier, Literal, Stmt, VisitorMut}; use crate::environment::Environment; use crate::error::Reporter; use crate::token::Position; #[derive(Clone, PartialEq)] pub enum FunctionKind { None, Function, // TODO: add more kinds supposedly...
true
c8c9e1d96894f5f15b4f08038170b7dc132d6616
Rust
ketralnis/hyperlogocomplete-rs
/src/make_hll.rs
UTF-8
2,322
2.671875
3
[]
no_license
use std::io; use std::io::BufRead; use basichll::HLL; use clap::{App, Arg}; use itertools::Itertools; use super::model::HyperLogLogger; use super::ERROR_RATE; pub fn main(app_name: &str) { let matches = App::new(app_name) .arg( Arg::with_name("fname") .help("the path to the hl...
true
a2b1ab64613a77cddce7dfc029d9eb07e4ae4ee5
Rust
dbcfd/rust-rdkafka
/src/client.rs
UTF-8
14,150
2.5625
3
[ "MIT" ]
permissive
//! Common client functionalities. use crate::rdsys; use crate::rdsys::types::*; use std::ffi::{CStr, CString}; use std::mem; use std::os::raw::c_char; use std::os::raw::c_void; use std::ptr; use std::slice; use std::string::ToString; use std::time::Duration; use serde_json; use crate::config::{ClientConfig, NativeC...
true
e75c7e7dc7bdec4331443523591b4c40a498c414
Rust
statiolake/procon-lib-rs
/src/pcl/macros/mod.rs
UTF-8
3,997
3.4375
3
[]
no_license
//! 一部の面倒を解消するマクロ類を定義する。 //! //! Rust の安全志向な言語仕様には競プロに向かない設計もある。それらに多少の答えを与えるために用意さ //! れたマクロ類を集める。 //! //! 実際のドキュメントはクレートのルートに配置されている。 //! //! - [`rtl!`](../../macro.rtl.html) ― 複合代入演算子を右辺から評価するマクロ。 //! - [`matches!`](../../macro.matches.html) ― 標準の matches! と同様のもの (polyfill) 。 /// 複合代入演算子を右辺から評価するマクロ。 /// /// Rust で...
true
5c8c66a76fdf8640769236a95d0087665a9d8362
Rust
gcapell/aoc2020
/src/day10.rs
UTF-8
1,120
3.25
3
[]
no_license
use std::collections::VecDeque; use std::fs; use std::io; use std::io::BufRead; #[derive(Debug)] struct Adapter { value: i32, count: i64, } pub fn run() { let mut nums = io::BufReader::new(fs::File::open("input.txt").unwrap()) .lines() .filter_map(Result::ok) .map(|x| x.parse::<i32...
true
d1117d739be3c558cf5c36ffde6fb3f0264ad2f6
Rust
JulianSchmid/etherparse
/etherparse/src/internet/ipv4_exts_slice.rs
UTF-8
1,611
2.96875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::*; /// Slices of the IPv4 extension headers present after the ip header. /// /// Currently supported: /// * Authentication Header /// /// Currently not supported: /// * Encapsulating Security Payload Header (ESP) #[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] pub struct Ipv4ExtensionsSlice<'a> { ...
true
5d3d7877d04b330dab32b27d3d7c187e115d8c32
Rust
kvnallsn/auth-rs
/src/webauthn/common/cose/key/algorithm.rs
UTF-8
930
2.78125
3
[]
no_license
//! COSE Key Algorithms mod es256; use self::es256::ES256Params; use crate::common::cose::{constants::*, CoseError, CoseMap}; use serde::Deserialize; use serde_cbor::Value; #[derive(Clone, Debug, Deserialize)] pub enum CoseKeyAlgorithm { ES256(ES256Params), } impl CoseKeyAlgorithm { /// Parses a COSE Key Al...
true
d1c8288662b32aae50cc09669a1048d4e66f07f5
Rust
Txuritan/stry
/stry-common/src/lib.rs
UTF-8
872
2.734375
3
[ "MIT" ]
permissive
use std::{fmt, future::Future, pin::Pin}; pub mod nanoid; pub type BoxedFuture<'l, T> = Pin<Box<dyn Future<Output = T> + Send + 'l>>; #[derive(Debug, Hash, Ord, PartialOrd, Eq, PartialEq)] pub enum LibraryDetails { Curl { // TODO: add feature members number: &'static str, version: String,...
true
600c117cefb3ef3e284f04ef601a0481134a9baa
Rust
johnbcoughlin/fluids-c
/opencl/rusty/src/galerkin_2d/maxwell/unknowns.rs
UTF-8
6,296
2.671875
3
[]
no_license
extern crate rulinalg; use distmesh::distmesh_2d::ellipse; use galerkin_2d::galerkin::GalerkinScheme; use galerkin_2d::grid::{assemble_grid, ElementStorage, Grid}; use galerkin_2d::operators::FaceLift; use galerkin_2d::operators::FaceLiftable; use galerkin_2d::operators::{assemble_operators, Operators}; use galerkin_2...
true
59862a1160816b669253df0792690fbae9ecf5c6
Rust
alexandrejanin/cuivre
/src/input.rs
UTF-8
8,152
3.328125
3
[ "MIT" ]
permissive
use maths::Vector2i; use sdl2; pub use sdl2::{ event::{Event, WindowEvent}, keyboard::Keycode, mouse::MouseButton, }; use std::{collections::HashMap, error, fmt}; /// Errors related to input management. #[derive(Debug)] pub enum InputError { KeycodeNotFound(Keycode), KeybindNotFound(String), Mo...
true
8b9298add46d8b9fe0eea4c2e5214b00f68efc66
Rust
IceyBlackTea/learn_algorithms_with_rust
/src/main.rs
UTF-8
1,898
2.71875
3
[]
no_license
/* * @Author: One_Random * @Date: 2021-03-14 20:50:52 * @LastEditors: One_Random * @LastEditTime: 2021-06-04 19:02:50 * @FilePath: /learn_algorithms_with_rust/src/main.rs * @Description: Copyright © 2020 One_Random. All rights reserved. */ // mod hello; // fn hello_test() { // hello::print_hello(); // } us...
true
8e7cc3a82a42e000e3942d414f849f0f5cf1fc3f
Rust
kvnvelasco/rsync-rust-ffi
/src/file/delta.rs
UTF-8
3,282
2.6875
3
[]
no_license
use crate::file::signature::{Signature, SignatureImpl}; use crate::result::RsyncResult; use crate::stats::RsyncStats; use crate::utilities::{fopen_with_string, join_to_path_then_string, string_from_path_ref}; use libc::{fclose, FILE}; use std::fs::File; use std::io::Read; use std::path::Path; use tempfile::tempdir; #[...
true
0e8eacf0c6c6628f8bf8bd8bb5e8670405e9282b
Rust
dennisss/dacha
/pkg/datastore/src/meta/tests.rs
UTF-8
7,233
2.609375
3
[ "Apache-2.0" ]
permissive
use common::errors::*; use crypto::random::{SharedRng, SharedRngExt}; use executor::child_task::ChildTask; use file::temp::TempDir; use protobuf::text::ParseTextProto; use raft::proto::routing::RouteLabel; use super::client::{MetastoreClient, MetastoreClientInterface}; use crate::meta::test_store::TestMetastore; use c...
true
0f45df0154a0c8d0db29afd75c17ce948d7a953d
Rust
Lasia98/Filecoin
/mirrors.ustc.edu.cn-b63e9dae659fc205/heim-memory-0.1.0-beta.1/src/sys/linux/swap.rs
UTF-8
4,425
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::fs; use std::io; use std::str::FromStr; use heim_runtime as rt; use heim_common::prelude::*; use heim_common::units::{information, Information}; static PROC_VMSTAT: &str = "/proc/vmstat"; static PROC_MEMINFO: &str = "/proc/meminfo"; #[derive(Debug, Default, Clone)] pub struct VmStat { swap_in: Option<I...
true
5e4dfd2de3401c2e6cfd48d90082cf6a6923b163
Rust
geniousli/point24
/src/algorithm/nc52.rs
UTF-8
1,153
3.484375
3
[]
no_license
use std::collections::VecDeque; struct Solution {} impl Solution { pub fn new() -> Self { Solution {} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @return bool布尔型 */ pub fn isValid(&self, s: String) -> bool { // write code here ...
true
fbd40d3f2c6ae04dd89a70329f7697ab2ad45277
Rust
Liano/procmon
/src/process/helper.rs
UTF-8
442
2.875
3
[]
no_license
use std::string::String; use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; pub fn get_string_from_wide(wide_array: &[u16]) -> Result<String, String> { let trimmed_wide = wide_array.iter() .position(|char| *char == 0) .map(|i| &wide_array[..i]) .unwrap_or(wide_array); let os_str = OsString...
true
981f5c540cd93b0f5c4387b961d1157b28f44672
Rust
Mishio595/momiji-rust
/src/commands/owner/cache.rs
UTF-8
1,119
2.515625
3
[ "MIT" ]
permissive
// use momiji::core::consts::*; use momiji::Context; use momiji::framework::args::Args; use momiji::framework::command::{Command, Options}; use twilight_model::channel::Message; use std::sync::Arc; use std::error::Error; pub struct CacheStats; #[async_trait] impl Command for CacheStats { fn options(&self) -> Arc<O...
true
a66d0f54f0225d4a4d8fb96ad6e19d8e6211c687
Rust
yskaksk/c-in-rust
/lang/src/tokenize.rs
UTF-8
4,658
3.453125
3
[]
no_license
use std::cmp; use std::collections::VecDeque; #[derive(Clone, PartialEq, Debug)] pub enum TokenKind { TK_RESERVED, TK_IDENT, TK_NUM, TK_RETURN, TK_IF, TK_WHILE, TK_FOR, } use TokenKind::*; #[derive(Clone, Debug)] pub struct Token { pub kind: TokenKind, pub val: Option<u32>, pu...
true
26ea655dd4b64a8dbe438e2ca41e6fd1e4f9f292
Rust
dougtq/rust-lang
/playground/hyper-fun/src/main.rs
UTF-8
477
2.515625
3
[ "MIT" ]
permissive
extern crate hyper; use hyper::{Body, Response, Server}; use hyper::rt::Future; use hyper::service::service_fn_ok; static TEXT: &str = "Hello, World!"; fn main() { let addr = ([127, 0, 0, 1], 3000).into(); let new_svc = || { service_fn_ok(|_req|{ Response::new(Body::from(TEXT)) }...
true
2e92dc7546851c8d4a4efbbdd4a9b3e3fff560a8
Rust
GKnirps/adventofcode-2019
/day-09/src/main.rs
UTF-8
1,047
2.59375
3
[]
no_license
use intcode::{parse, run_program, State}; use std::env; use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; fn main() -> Result<(), String> { let filename = env::args() .nth(1) .ok_or_else(|| "No file name given.".to_owned())?; let content = read_file(&Path::new(&filename))....
true
d2faea4209508ffd7cb6f6ac368b35e0e12626c6
Rust
gabriel-araujjo/ad-hoc-parse-tables
/src/parse.rs
UTF-8
5,341
3.515625
4
[]
no_license
use std::{fmt::Display, mem::swap}; #[derive(Debug)] pub enum ParseStatus { SearchingTable, SearchingField, SearchingCol1, Col1(String), SearchingCol2(String), Col2(String, String), Field(String, String), Finished, } #[derive(Debug)] pub struct ParseError { message: String, } impl...
true
6e8ebdd433f64623ef190c6fe67711078254787b
Rust
Eldhrimer/spot
/src/app/components/utils.rs
UTF-8
4,131
2.90625
3
[ "MIT" ]
permissive
use gtk::prelude::*; use std::cell::Cell; use std::rc::Rc; use std::time::Duration; #[derive(Clone)] pub struct Clock { interval_ms: u32, source: Rc<Cell<Option<glib::source::SourceId>>>, } impl Default for Clock { fn default() -> Self { Self::new(1000) } } impl std::fmt::Debug for Clock { ...
true
0b548cdf59868755dea2a7a2b537b7ca744e2df1
Rust
rustkas/Traits-from-the-Ground-Up
/data_and_behavior/src/add_method.rs
UTF-8
437
2.796875
3
[]
no_license
/* cargo run -p data_and_behavior --bin add_method */ #[derive(Debug, PartialEq)] struct Fact { text: String, } impl Fact { fn make_true(&self) -> Fact { Fact { text: format!("{}!!", self.text), } } } fn main() { let fact = Fact { text: String::from("Lorem ipsum"),...
true
951041542b643aa90de9269461725b6a690320b8
Rust
shaneutt/aws-lambda-rust-runtime
/lambda-http/src/lib.rs
UTF-8
6,005
2.796875
3
[ "Apache-2.0" ]
permissive
#![warn(missing_docs)] //#![deny(warnings)] //! Enriches the `lambda` crate with [`http`](https://github.com/hyperium/http) //! types targeting AWS [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html), [API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/wel...
true
b6f9ddae567df64d3ed8032df5f0cfbda1b80824
Rust
jsjoeio/rusty-bunny
/src/utils/localhost.rs
UTF-8
848
3.296875
3
[ "MIT" ]
permissive
pub fn construct_localhost_url(query: &str) -> String { // default if query == "lh" { let localhost = "http://localhost:3000"; localhost.to_string() } else { // Assume the other match is "localhost:PORT" // optimistic, eh? let port = &query[3..]; let localhos...
true
43994eda2b302e5b74a3f2847b1e8c00baa3b28e
Rust
trrichard/isomidi
/src/main.rs
UTF-8
17,761
2.8125
3
[]
no_license
extern crate sdl2; extern crate midir; mod keyboard; use sdl2::rect::Rect; use sdl2::render::TextureQuery; use std::{thread}; use std::time::{Instant,Duration}; use sdl2::pixels::Color; use sdl2::ttf::Font; use sdl2::event::Event; use sdl2::event::WindowEvent; use sdl2::keyboard::Keycode; use sdl2::gfx::primitives::Dr...
true
cfc311d3800c63135025e428f1bae6706ab10452
Rust
lightsofapollo/toml-json-rs
/src/bin/json-toml.rs
UTF-8
1,440
2.875
3
[]
no_license
extern crate getopts; extern crate tomljson; use std::{env, process, path}; use std::fs::File; use tomljson::JsonConverter; use getopts::Options; static USAGE: &'static str = "Convert json file to toml and print to stdout"; fn show_help(opts: Options) { println!("{}", opts.usage(USAGE)); } fn main() { // ma...
true
d47d518f2a65963c9d5002498e707f1e31da8668
Rust
dsietz/rust-daas
/src/sourcing.rs
UTF-8
3,786
2.5625
3
[ "Apache-2.0" ]
permissive
use super::*; use actix_web::{App, http, HttpRequest, HttpResponse, Path}; use actix_web_httpauth::extractors::basic::BasicAuth; use super::daas::DaaSDoc; use super::couchdb::{CouchDB}; use std::thread; /// globals static DB_NAME: &str = "sourcing"; static DB_USER: &str = "admin"; static DB_PSWRD: &str = "password"; ...
true
43740dced0b61c765658b809812702a7a318f0cc
Rust
booyaa/bottymcbottyface
/examples/mouthpiece.rs
UTF-8
4,861
2.734375
3
[ "Apache-2.0" ]
permissive
#![allow(unused_must_use)] extern crate hiirc; extern crate clap; use std::sync::Arc; use hiirc::*; use clap::{Arg, App}; // this code is largely inspired (copied) by the peekaboo example in hiirc. const APP_VERSION: &'static str = concat!("(", env!("CARGO_PKG_NAME"), ...
true
540a07eb96a39ec87e3138eb70550a5188ae9f23
Rust
Byron/gitoxide
/gix-packetline/tests/write/mod.rs
UTF-8
2,010
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
#[cfg(feature = "blocking-io")] use std::io::Write; use bstr::ByteSlice; #[cfg(all(feature = "async-io", not(feature = "blocking-io")))] use futures_lite::prelude::*; use gix_packetline::Writer; const MAX_DATA_LEN: usize = 65516; const MAX_LINE_LEN: usize = 4 + MAX_DATA_LEN; #[allow(clippy::unused_io_amount)] // und...
true
e785e0bf7cbde89d7657f038a3ec3431303b5305
Rust
Jacobious52/picky
/examples/ps.rs
UTF-8
471
2.65625
3
[]
no_license
use std::process::Command; use std::str; use picky; fn main() { let output = Command::new("ps").arg("aux").output().unwrap(); if !output.status.success() { panic!("Command executed with failing error code"); } let lines: Vec<_> = str::from_utf8(&output.stdout).unwrap().lines().collect(); ...
true
184dfbc0e397df8932b0b200031a2e14428dd7b4
Rust
EcomDev/rust-mysql-proxy
/src/lib/mysql/value_mapper.rs
UTF-8
7,267
2.71875
3
[]
no_license
use crate::lib::messages::{Column, TypeHint, Value}; use mysql_async::{consts::ColumnType, Column as MySQLColumn, Value as MySQLValue}; use std::sync::Arc; pub(super) fn map_values_to_mysql_values(values: Vec<Value>) -> Vec<MySQLValue> { values.into_iter().map(|value| value.into()).collect() } pub(super) fn map_m...
true
9ccadf3d8c03292a5f3ee59ed25da69624960c12
Rust
j127/rust_cli_book_grrs
/src/main.rs
UTF-8
2,478
3.34375
3
[]
no_license
use std::{thread, time}; use log::{info, warn}; use structopt::StructOpt; use failure::ResultExt; use exitfailure::ExitFailure; use indicatif::ProgressBar; /// Search for a pattern in a file and display the lines that contain it. #[allow(dead_code)] #[derive(StructOpt)] struct Cli { /// The pattern to look for ...
true
12cd332e5a10c30bfcdfac8e1d61fcd58122992d
Rust
Speedy37/vcdiff-rs
/src/varint.zigzag.rs
UTF-8
10,066
2.890625
3
[ "MIT" ]
permissive
use std::cmp::PartialEq; use std::mem; use std::io::{Error, Write}; trait ZigZag<T> { fn zigzag(self) -> T; } macro_rules! impl_zigzag { ($IT:ty, $UT:ty) => { impl ZigZag<$IT> for $UT { fn zigzag(self) -> $IT { ((self >> 1) ^ (-((self & 1) as $IT)) as $UT) as $IT }...
true
54ba1cfcfa93dbeef8eebad79d779f3e10ea684b
Rust
EmbarkStudios/imgui-rs
/imgui-glow-renderer/src/versions.rs
UTF-8
6,213
2.953125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![allow(clippy::must_use_candidate)] #[derive(PartialEq, Clone, Copy)] pub struct GlVersion { pub major: u16, pub minor: u16, pub is_gles: bool, } impl GlVersion { pub const fn gl(major: u16, minor: u16) -> Self { Self { major, minor, is_gles: false, ...
true
9f8a664bf31a7102318c8aeb5ef74804276d887e
Rust
stm32-rs/stm32g0xx-hal
/src/dma.rs
UTF-8
12,603
3.34375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-unknown" ]
permissive
//! Direct Memory Access Engine use crate::dmamux::DmaMuxIndex; use crate::rcc::Rcc; use crate::stm32::DMAMUX; /// Extension trait to split a DMA peripheral into independent channels pub trait DmaExt { /// The type to split the DMA into type Channels; /// Reset the DMA peripheral fn reset(self, rcc: &...
true
d87013b477cdf01219af8b091a94d8600b56fdab
Rust
Ralakus/mod-language
/libs/ansi/src/lib.rs
UTF-8
5,276
2.953125
3
[ "MIT" ]
permissive
//! ANSI color coding helper for mod_language #![warn(missing_docs)] #![warn(clippy::all)] #![allow(clippy::useless_let_if_seq)] use std::{ fmt::{ Display, Debug, Formatter, Result as FMTResult, }, }; #[cfg(windows)] mod windows { const STD_OUTPUT_HANDLE: u32 = -11 as _; const ENABLE_VIRTUAL_TER...
true
803349350cb40524962ff4c820a8286c040fcc3a
Rust
iliekturtles/uom
/src/quantity.rs
UTF-8
17,594
3.171875
3
[ "MIT", "Apache-2.0" ]
permissive
/// Macro to implement a [quantity][quantity] and associated [measurement units][measurement]. Note /// that this macro must be executed in direct submodules of the module where the /// [`system!`](macro.system.html) macro was executed. `@...` match arms are considered private. /// /// * `$quantity_attr`: Quantity attr...
true
b8c15c754c84ea7b51c182a32f10d3baf563a241
Rust
jblindsay/whitebox-tools
/whitebox-common/src/structures/polynomial_regression_2d.rs
UTF-8
4,777
2.828125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::na::{DMatrix, DVector}; use std::f64::EPSILON; use std::io::Error; use std::io::ErrorKind; pub struct PolynomialRegression2D { poly_order: usize, pub num_coefficients: usize, pub coefficients: Vec<[f64; 2]>, pub residuals: Vec<f64>, } impl PolynomialRegression2D { pub fn new( po...
true
8ef2517712afdb2c08cca8b0a70d7c24e81130ce
Rust
sndyuk/shared_memory-rs
/shared_memory_derive/tests/ui/str.rs
UTF-8
612
3.203125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Since only `str` implements SharedMemCast, it should be impossible to store a `&str` in //! a struct and then derive SharedMemCast. This would be invalid anyway since you can't store //! references in shared memory. use shared_memory::SharedMemCast; #[derive(SharedMemCast)] pub struct MyStruct<'a> { x: &'a st...
true
6b445537ca09328a78946e0520453e4c304ac69d
Rust
zhangf911/kiss-ui
/src/container.rs
UTF-8
3,457
2.65625
3
[ "MIT" ]
permissive
use super::BaseWidget; #[derive(Copy, Clone)] pub enum VAlign { Top, Center, Bottom, } impl VAlign { fn as_cstr(self) -> &'static str { use self::VAlign::*; match self { Top => cstr!("ATOP"), Center => cstr!("ACENTER"), Bottom => cstr!("ABOTTOM"), ...
true
8861419ae062212c650f73371e3b59ea6064e853
Rust
35359595/csharp_rust_ffi_examples
/FFIProvider/src/lib.rs
UTF-8
1,218
3.09375
3
[ "MIT" ]
permissive
extern crate libc; use libc::c_char; use std::ffi::CString; #[no_mangle] pub extern fn double_num(n: isize) -> isize { n * 2 } #[no_mangle] pub extern fn get_string() -> *mut c_char { CString::new("Hello").unwrap().into_raw() } #[no_mangle] pub extern fn to_lower(s: *mut c_char) -> *mut c_char { unsafe ...
true
042b7e9fdaf4c83a509f28951b90c80ed2526b9e
Rust
akiles/embassy
/embassy-time/src/driver.rs
UTF-8
6,979
3.390625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Time driver interface //! //! This module defines the interface a driver needs to implement to power the `embassy_time` module. //! //! # Implementing a driver //! //! - Define a struct `MyDriver` //! - Implement [`Driver`] for it //! - Register it as the global driver with [`time_driver_impl`](crate::time_driver_i...
true
0d19fcfa84f4a09fbeb31da8b559b000014fb474
Rust
Chosenundead15/psxero
/src/memory.rs
UTF-8
9,574
2.828125
3
[]
no_license
use std::path::Path; use std::io::Read; use std::fs::File; pub mod map { //a trick to simplify figuring out what part of memory belongs the address const REGION_MASK: [u32; 8] = [ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, //KUSEG: 2048MB 0x7fffffff, //KSEG0: 512MB 0x1fffffff, //KS...
true
92feaa293dcc603cdb7409e2bb92d0eee47b3ca6
Rust
dongggcom/record
/rustlings/enums/enum3.rs
UTF-8
1,470
3.921875
4
[]
no_license
#[derive(Debug)] enum Message { // TODO: implement the message variant types based on their usage below ChangeColor(i32,i32,i32), Echo(String), Quit, Move(Point) } #[derive(Debug)] struct Point { x: u8, y: u8 } struct State { color: (u8, u8, u8), position: Point, quit: bool } i...
true
59d9e5246fe3d76c4d9c09b59eb9bb6b924dc84a
Rust
kisasexypantera94/khalzam-rs
/src/lib.rs
UTF-8
3,131
3.5
4
[ "MIT" ]
permissive
//! `khalzam` is an audio recognition library //! that makes it easy to index and recognize audio files. //! It focuses on speed, efficiency and simplicity. //! //! Its algrorithm is based on [this article]. //! //! [this article]: https://royvanrijn.com/blog/2010/06/creating-shazam-in-java/ pub mod db; mod fingerprint...
true
19365e46aa8e24880c032f3cbfd3487954f2f27d
Rust
dtolnay/proc-macro-workshop
/debug/tests/01-parse.rs
UTF-8
740
2.921875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
// This test looks for a derive macro with the right name to exist. For now the // test doesn't require any specific code to be generated by the macro, so // returning an empty TokenStream should be sufficient. // // Before moving on, have your derive macro parse the macro input as a // syn::DeriveInput syntax tree. //...
true
74ecf9416ae1242b2bf86a0fdd28caa29297fa8c
Rust
yiwang/ultra
/src/app/canvas/timeline.rs
UTF-8
2,044
2.59375
3
[ "MIT" ]
permissive
use super::prelude::*; use tui::layout::{Layout, Constraint}; use tui::widgets::Gauge; use tui::style::Modifier; use crate::utils::display_duration; use std::sync::atomic::Ordering; #[derive(Debug)] pub struct Timeline { pub win_id: u64, pub area: Rect, } impl Default for Timeline { #[inline] fn defau...
true
a3f0a732e184be48fc85f753eb5275c8f8c8b712
Rust
Phantom217/aoc2019
/src/day07.rs
UTF-8
4,877
2.953125
3
[]
no_license
use crossbeam::channel; use itertools::Itertools; use crate::computer::{Channel, ComputerMT, Queue, Rom}; use crate::error::Error; use crate::utils::math; // Representation of amplification to Intcode computer for Day 7: // // chan4 chan0 chan1 chan2 chan3 chan4 // ...------- c...
true
9dc1a296f32b6ffbd3caf7585775c64d92aaedc3
Rust
comit-network/secp256kfun
/secp256kfun/src/backend/parity/mod.rs
UTF-8
6,337
2.640625
3
[ "0BSD" ]
permissive
pub use parity_backend::scalar::Scalar; use parity_backend::{ ecmult::{ECMultContext, ECMultGenContext}, field::Field, group::{Affine, Jacobian, JACOBIAN_INFINITY}, }; mod constant_time; mod variable_time; pub use constant_time::ConstantTime; pub use variable_time::VariableTime; pub type Point = Jacobian; ...
true
812fdc9ab06f33b841011cf7dc66e717ee36f5a4
Rust
diogotcorreia/advent-of-code
/2022/src/day08.rs
UTF-8
3,828
3.03125
3
[ "MIT" ]
permissive
use std::collections::HashSet; use crate::AocDay; #[derive(Debug)] struct Forest(Vec<u8>, usize); impl Forest { fn new(side: usize) -> Forest { Forest(Vec::new(), side) } fn push(&mut self, height: u8) { self.0.push(height); } fn iter_row(&self, row: usize) -> impl DoubleEndedIt...
true
39fa9f988134ece52416ec87916d7baad1dd16a3
Rust
Axect/Peroxide
/src/util/api.rs
UTF-8
1,856
3.03125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Choose api - MATLAB, R, Python use crate::structure::matrix::*; use std::convert; pub trait MATLAB { fn new(s: &str) -> Self; } pub trait PYTHON { fn new<T>(v: Vec<Vec<T>>) -> Self where T: convert::Into<f64> + Copy; } pub trait R { fn new<T>(v: Vec<T>, x: usize, y: usize, shape: Shape) ...
true
3ba30369e9ed60be09d0c30b4f4d8871602a7731
Rust
kurtlawrence/kserd
/tests/formatting.rs
UTF-8
15,407
2.96875
3
[ "MIT" ]
permissive
#![cfg(feature = "encode")] extern crate kserd; #[macro_use] extern crate serde_derive; use kserd::encode::Serialize; use kserd::fmt::*; use kserd::*; use std::collections::BTreeMap; fn encode_map<'a, I, K, V>(i: I) -> impl Iterator<Item = (Kserd<'a>, Kserd<'a>)> where I: Iterator<Item = &'a (K, V)>, K: Seria...
true
7dfe6153353566db024cbdbf6c898b7736a106bb
Rust
ibenberge/abi_stable_crates
/abi_stable/src/type_layout/construction.rs
UTF-8
3,151
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use super::*; //////////////////////////////////////////////////////////////////////////////// /// The parameters for `TypeLayout::from_params`. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] pub struct TypeLayoutParams { /// The name of the type,without generic parameters. pub name: &'static str, ...
true
75bba901b7e698fce9255ab52ef6807d0197cc5c
Rust
BenjaminHinchliff/ashpaper-plus
/src/bin/ashpaper-plus.rs
UTF-8
2,115
2.75
3
[ "MIT" ]
permissive
use ashpaper_plus::Program; use clap::{App, Arg, ArgMatches}; use std::fs; #[cfg(feature = "jit")] fn conditional_jit_arg<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { app.arg( Arg::with_name("jit") .short("j") .long("jit") .help("Enable high performace jit compilation with...
true
0dca8f22b8e19d5fae4bf892bbbc2d87d6c8eac8
Rust
sh0623k/coding_interview
/src/bin/ch08p01.rs
UTF-8
998
3.578125
4
[]
no_license
/* 問題: 子供がn段の階段を駆け上がりますが、一歩で1段、2段もしくは3段登れる。このとき、考え得る階段の上り方が何通りあるか求めるメソッドを実装する。 */ // 場合の数の計算は整数型だとオーバーフローしやすい. // 再帰の形で書いてもいい. fn triple_step(size: usize) -> usize { if size < 3 { return size } if size == 3 { return 4 } let mut table = vec![0; size + 1]; table[0] = 1; tab...
true
631e8031000e32c174c85bd160bdfefdc06b7aef
Rust
mopp/CodeGarage
/rust/move.rs
UTF-8
293
3.203125
3
[]
no_license
#[derive(Debug)] struct A(usize, usize); fn mover(a: A) -> A { let A(x, y) = a; A(x + 100, y + 100) } fn main() { let a = A(1, 1); println!("{:?}", a); let b = mover(a); // error[E0382]: use of moved value: `a` // println!("{:?}", a); println!("{:?}", b); }
true
58412d8b0f6eb02babd185897de1736c0979a691
Rust
roynalnaruto/core
/crates/sol-macro/src/expand/function.rs
UTF-8
4,581
2.671875
3
[ "Apache-2.0", "MIT" ]
permissive
//! [`ItemFunction`] expansion. use super::{ expand_fields, expand_from_into_tuples, expand_from_into_unit, expand_tuple_types, r#type::expand_tokenize_func, ExpCtxt, }; use ast::ItemFunction; use proc_macro2::TokenStream; use quote::quote; use syn::Result; /// Expands an [`ItemFunction`]: /// /// ```ignore,p...
true
517385e92c780cba58aedf9017b7b452e62b811e
Rust
BoringStudio/libembercore
/src/tme/models/map.rs
UTF-8
2,356
2.796875
3
[ "Apache-2.0" ]
permissive
use std::str::FromStr; use serde::Deserialize; use serde::Serialize; use super::hexagonal_map::HexagonalMap; use super::isometric_map::IsometricMap; use super::orthogonal_map::OrthogonalMap; use super::staggered_map::StaggeredMap; use crate::tme::error::Error; #[derive(Debug, Serialize, Deserialize)] #[serde(tag = ...
true
ca91c4c9d2c0b4cb0d227d904a79b1c0e8185ded
Rust
chromium/chromium
/third_party/rust/syn/v1/crate/src/spanned.rs
UTF-8
3,773
3.46875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0", "BSD-3-Clause", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
//! A trait that can provide the `Span` of the complete contents of a syntax //! tree node. //! //! *This module is available only if Syn is built with both the `"parsing"` and //! `"printing"` features.* //! //! <br> //! //! # Example //! //! Suppose in a procedural macro we have a [`Type`] that we want to assert //! ...
true
2fd3ba61532d5990a43960fbfc24c0c44fbab8be
Rust
irevoire/inquire
/src/type_aliases.rs
UTF-8
1,999
3.5625
4
[ "MIT" ]
permissive
//! General type aliases. /// Type alias to represent the function used to filter options. /// /// The function receives: /// - Current user input, filter value /// - Current option being evaluated, with type preserved /// - String value of the current option /// - Index of the current option in the original list /// ...
true
e6dd8ab115538a76a3b7e3eda8c6c086e74fe6bf
Rust
najamelan/runng
/runng/src/dialer.rs
UTF-8
1,503
2.609375
3
[ "MIT" ]
permissive
//! Dialer use super::*; use runng_derive::{NngGetOpts, NngSetOpts}; use runng_sys::*; /// Wraps `nng_dialer`. See [nng_dialer](https://nanomsg.github.io/nng/man/v1.1.0/nng_dialer.5). #[derive(NngGetOpts, NngSetOpts)] #[prefix = "nng_dialer_"] pub struct NngDialer { #[nng_member] dialer: nng_dialer, sock...
true
0d15259154b7e14c22ac1b0f88b756735eea257d
Rust
aaronshappell/advent-of-code-2020
/src/day9.rs
UTF-8
1,770
3.234375
3
[]
no_license
use std::{collections::HashSet, fs}; pub fn run(){ let input = fs::read_to_string("inputs/day9.txt").expect("Failed to read file"); let raw_data: Vec<u64> = input.lines().map(|line| line.parse::<u64>().unwrap()).collect(); part1(&raw_data); part2(&raw_data); } fn part1(raw_data: &[u64]) { let xma...
true
43aa81ac39b0a0c6b3198d910e1afa18393a9011
Rust
holmesmr/nicegit-rs
/src/types.rs
UTF-8
935
3.03125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use git2::TreeEntry; /// A friendly interface to a 'directory' in git, which is a snapshot of a node in the /// working tree at a specific commit which would be mapped to a file system directory /// by a Git client, which is a flat, single level of a subtree. The directory and file nodes /// are split into two separat...
true
edf9030f4fcde1040aecd1e8b3989425f6e9edc5
Rust
millerjs/resbuild
/src/common.rs
UTF-8
5,179
2.640625
3
[]
no_license
use ::types::*; use ::graph::CachedGraph; impl TypeTree { pub fn new<S>(label: S, title: S, correlation: Correlation) -> TypeTree where S: Into<String> { TypeTree { label: label.into(), title: title.into(), correlation: correlation, children: Vec...
true
aafdd2c9f70d339b6bfae939f0c6b958f5228a9f
Rust
weiznich/rustorm
/crates/dao/src/error.rs
UTF-8
336
2.640625
3
[ "MIT" ]
permissive
use thiserror::Error; #[derive(Error, Debug)] pub enum ConvertError { #[error("Conversion not supported {0} to {1}")] NotSupported(String, String), } #[derive(Error, Debug)] pub enum DaoError { #[error("ConvertError {0}")] ConvertError(ConvertError), #[error("No such value {0}")] NoSuchValueE...
true
8bbf9cd6d176fcddce659a7fb228d76c6e8b14ed
Rust
defyrlt/lithium
/src/select/order_by.rs
UTF-8
1,122
3.578125
4
[ "MIT" ]
permissive
#[allow(dead_code)] #[derive(Clone, PartialEq, Eq)] pub enum Ordering { Ascending, Descending, } impl Ordering { pub fn to_sql(&self) -> &str { match *self { Ordering::Ascending => "ASC", Ordering::Descending => "DESC" } } } #[derive(Clone, PartialEq, Eq)] pub s...
true
62086668b2bae3354c933c0b0616f37d9e0f78fc
Rust
khoek/iota
/src/data/decode.rs
UTF-8
5,544
2.796875
3
[]
no_license
use console::{style, Color}; use single::Single; use std::fmt::{Display, Write}; use super::model; impl Display for model::DeviceState { fn fmt(&self, out: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { match self { model::DeviceState::Up => write!(out, "{}", style("Up").green(...
true
bd4a563a8f03a583db938d4ed392c4af9bac62d3
Rust
sogapalag/contest
/atcoder/tenka1-2016-qualb/e.rs
UTF-8
4,873
2.703125
3
[]
no_license
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufRea...
true
fa87c9b0f0ffd2a6e9abe703c57a3926c433535e
Rust
stranger80/golem-market-api
/src/resolver/expression.rs
UTF-8
23,189
3
3
[ "MIT" ]
permissive
use std::str; use asnom::structures::{ExplicitTag, OctetString, Tag}; use super::errors::{ExpressionError, ResolveError}; use super::ldap_parser; use super::properties::{parse_prop_ref, Property, PropertyRef, PropertySet, PropertyValue}; // Expression resolution result enum #[derive(Debug, Clone, PartialEq)] pub enu...
true
e73c04e513d373176c43d49fddb6f6323252daec
Rust
niconical/RustConcepts
/exam/src/main.rs
UTF-8
1,022
3.4375
3
[]
no_license
const NUMBER: [&str; 12] = [ "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "11th", "12th", ]; fn song_of_christmas(n: usize) { match n { 0 => println!("A partridge in a pear tree"), 1 => println!("Two turtle doves, and"), 2 => println!("Three frenc...
true
f3893843cd4cd8cb7a63b23c67b55ec2fbd978b0
Rust
ray-kast/Ingot
/src/danger.rs
UTF-8
1,357
2.78125
3
[]
no_license
use glib::WeakRef; use gtk::{IsA, Object, ObjectExt}; use std::ops::Deref; // NB: I'm only doing this because these types are only accessed either directly // on the main thread, or inside an idle callback #[derive(Clone)] pub struct Danger<T>(T) where T: IsA<Object>; unsafe impl<T> Send for Danger<T> where T:...
true
4dfda52f0092f8023bd8d5013679fa3a17490921
Rust
mthaler/cryptography
/src/onetimepad.rs
UTF-8
2,161
3.609375
4
[]
no_license
use rand::Rng; pub fn encrypt(msg: String, key: &Vec<u8>) -> Result<Vec<u8>, &'static str> { let m = msg.into_bytes(); if m.len() > key.len() { Err("key to short") } else { let mut b: Vec<u8> = Vec::new(); let mut i = 0; while i < m.len() { let x = m[i]; ...
true
a36f5b0e4d4cf43e227675f580138c61b2e02602
Rust
hasenbanck/asche
/src/semaphore.rs
UTF-8
3,767
2.765625
3
[ "MIT", "Apache-2.0", "Zlib" ]
permissive
use std::sync::Arc; use erupt::vk; #[cfg(feature = "tracing")] use tracing1::error; use crate::context::Context; use crate::{AscheError, Result}; /// A handle of a binary semaphore. #[derive(Debug, Clone, Copy)] pub struct BinarySemaphoreHandle(pub(crate) vk::Semaphore); /// A handle of a timeline semaphore. #[deri...
true
e04df3e9f9592fff9bd12e715bdb1191c2ba5a9d
Rust
ru-engineering/Solutions
/ia_6.rs
UTF-8
694
2.984375
3
[]
no_license
use rpi_embedded::pwm::{Pwm,Channel,Polarity}; use std::time::Duration; use std::thread; fn main(){ let stp = Stepper::new(Channel::Pwm0, Duration::from_millis(100), Duration::from_millis(0)); stp.steps(100); } struct Stepper{ pwm : Pwm, period : Duration, } impl Stepper{ fn new(channel:Channel,period_inn...
true
6338d2570075a2119db01a27d4c4347993f0100f
Rust
Kryndex/rust-zipkin
/zipkin/src/annotation.rs
UTF-8
3,474
2.859375
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 Palantir Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicabl...
true
aeadfd1d86bf07751278044bf047c7f2e3ddabf8
Rust
andor44/kubeclient
/src/api/core/v1/secret.rs
UTF-8
2,025
2.609375
3
[]
no_license
use std::fmt; use std::collections::HashMap; use base64; use serde::{Serialize, Serializer}; use serde::de::{self, Visitor, Deserialize, Deserializer}; use crate::api; use crate::apimachinery::apis::meta; use super::{API_GROUP, API_VERSION}; // Secret type SecretType = String; pub struct SecretData(pub Vec<u8>); ...
true
57f151748045739f37639321f4de9379b62cbb36
Rust
ylambda/rust-tiny-interpreter
/src/main.rs
UTF-8
5,197
3.875
4
[]
no_license
extern crate regex; use regex::Regex; fn main() { } struct Token { name: &'static str, value: String, } fn tokenize(input: &str) -> Vec<Token> { let chars = input.chars().collect::<Vec<char>>(); let mut tokens = Vec::new(); let mut index = 0; let whitespace = Regex::new(r"\s").unwrap(); ...
true
f87aacdfaa2ed9286f1483faf97a7666dcfa6ae7
Rust
mdaley/timer_rust
/src/timer.rs
UTF-8
6,869
3.28125
3
[]
no_license
extern crate custom_error; use custom_error::custom_error; use std::sync::mpsc; use std::thread; use std::sync::mpsc::{Receiver, SendError, Sender}; use crate::timer::TimerError::{AlreadyStopped, NotRunning, AlreadyStarted}; custom_error! {#[derive(PartialEq)] pub TimerError AlreadyStopped = "Cannot stop an alrea...
true
b6821180403e8bcc46446dab0abd8cb97bfd3b1c
Rust
TheooAndre/rust-beginner-projects
/src/rock_paper_scissors.rs
UTF-8
5,301
4
4
[]
no_license
//! # Rock, Paper, Scissors //! This example isn't the shortest but I did it to show some //! operator overloading and implementing traits on a struct //! (and learn how to do it in the process) use rand::seq::SliceRandom; use std::cmp::{Ord, Ordering}; use std::fmt; use std::io::{self, Write}; /// A Rock, Paper, Sci...
true
dded57e5fba55626f4b49dcd627d905189902830
Rust
wfxr/rust
/exercises/practice/simple-cipher/src/lib.rs
UTF-8
438
3.09375
3
[ "MIT" ]
permissive
pub fn encode(key: &str, s: &str) -> Option<String> { unimplemented!("Use {} to encode {} using shift cipher", key, s) } pub fn decode(key: &str, s: &str) -> Option<String> { unimplemented!("Use {} to decode {} using shift cipher", key, s) } pub fn encode_random(s: &str) -> (String, String) { unimplemente...
true
f119ab156662d93fc111b9ad240af5e545b453cd
Rust
RichoDemus/relax
/src/core.rs
UTF-8
4,352
2.78125
3
[ "Apache-2.0" ]
permissive
use std::thread::sleep; use std::time::Duration; use reqwest::blocking::Client; use serde_json::Value; use crate::oauth; use crate::servo_controller::ServoController; pub(crate) struct Core { client_id: Option<String>, client_secret: Option<String>, token: Option<String>, user_id: Option<String>, ...
true
645899388e672b441a7741f8da51433869d1769b
Rust
rphmeier/parity-wasm
/src/interpreter/module.rs
UTF-8
19,590
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::HashMap; use std::iter::repeat; use std::sync::{Arc, Weak}; use elements::{Module, InitExpr, Opcode, Type, FunctionType, FuncBody, Internal}; use interpreter::Error; use interpreter::imports::ModuleImports; use interpreter::memory::MemoryInstance; use interpreter::program::ProgramInstanceEssence; ...
true
6193e91fd6fe65a10e87d31337cc35d1d3a1d909
Rust
giodamelio/little_boxes
/vendor/snapbox/examples/snap-example-fixture.rs
UTF-8
1,507
2.890625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! For `snapbox`s tests only use std::env; use std::error::Error; use std::io; use std::io::Write; use std::process; fn run() -> Result<(), Box<dyn Error>> { if let Ok(text) = env::var("stdout") { println!("{}", text); } if let Ok(text) = env::var("stderr") { eprintln!("{}", text); } ...
true
7c5de90bbda5f8a72a60aa68c1a8842cccfaedf7
Rust
jaredly/gravitron-js
/gravitron.rs
UTF-8
6,194
2.859375
3
[]
no_license
extern crate native; extern crate rsfml; extern crate std; extern crate rand; extern crate collections; use rsfml::system::Vector2f; use rsfml::window::{ContextSettings, VideoMode, event, Close}; use rsfml::graphics::{RenderWindow, CircleShape, Color}; use rand::random; use collections::{HashMap}; #[start] fn start(...
true
1a8c710e906a46da028562385773e2d4ad756628
Rust
oliver-giersch/conquer-util
/src/lib.rs
UTF-8
2,667
2.9375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Common utilities for lock-free and concurrent programming. //! //! This crate provides fine-grained control over its contents through cargo //! feature flags: //! //! # `#![no_std]` Compatibility //! //! By default, `conquer-utils` enables the `std` feature, which links against //! the standard library and requires...
true
3d1d1a0c1343c46636b3bd41fac9d1c07c7c8e9a
Rust
fredyw/leetcode
/src/main/rust/src/bin/problem2467.rs
UTF-8
4,391
2.921875
3
[ "MIT" ]
permissive
use std::collections::{HashMap, HashSet, VecDeque}; // https://leetcode.com/problems/most-profitable-path-in-a-tree/ pub fn most_profitable_path(edges: Vec<Vec<i32>>, bob: i32, amount: Vec<i32>) -> i32 { fn build_graph(edges: &Vec<Vec<i32>>) -> HashMap<i32, Vec<i32>> { let mut map: HashMap<i32, Vec<i32>> =...
true
0eb0624737da24e3e288423a985d008a9000979a
Rust
kawadumax/task-generator
/src/mode.rs
UTF-8
1,476
3
3
[]
no_license
use crate::data_generator::DataGenerator; use crate::task_builder::TaskBuilder; pub struct ModeController { mode: Box<dyn Mode>, } impl ModeController { pub fn new(mode: Box<dyn Mode>) -> Self { Self { mode } } pub fn make(self) { self.mode.make() } } pub trait Mode { fn make...
true
048f3578eff3ca89a0394ce2da6ef50dc1b28b0f
Rust
Jacobious52/AdventOfCode2020
/src/bin/day03.rs
UTF-8
1,360
3.125
3
[]
no_license
use std::vec; use advent_of_code_2020::advent::util; fn main() { color_backtrace::install(); let input = include_str!("../../inputs/3.1.txt"); let map = parse_map(input); println!("part01 {}", part01(&map, (1, 3))); println!("part02 {}", part02(&map)); } fn part01(map: &[Vec<String>], slope: (usi...
true
2f7418073ab693792d123f9a5dbd6bb66c574b77
Rust
BurntSushi/memchr
/bench/src/memmem/mod.rs
UTF-8
15,249
2.703125
3
[ "Unlicense", "MIT" ]
permissive
/* This module defines benchmarks for the memmem family of functions. Benchmarking a substring algorithm is particularly difficult, especially when implementations (like this one, and others) use heuristics to speed up common cases, typically at the expense of less common cases. The job of this benchmark suite is to no...
true
1263d7f283eebfd0398c13a814643abd56a2f39f
Rust
cz-fish/advent-of-code
/2016/src/07.rs
UTF-8
4,942
3.53125
4
[ "MIT" ]
permissive
use std::fs::File; use std::io::Read; use std::collections::HashSet; /// Given a string of characters, return true if there is any substring /// that is an even palindrome of length 4 and the shape ABBA /// (A and B being two different characters) fn has_even_palindrome(chunk: &str) -> bool { let chars: Vec<char> ...
true
9062d59e58a1520bbf1461adef6d16539db69997
Rust
mimblewimble/easy-jsonrpc
/examples/udp_connect.rs
UTF-8
2,794
2.609375
3
[ "Apache-2.0" ]
permissive
//! sends requests to the server defined in udp_listener #[allow(dead_code)] mod common; use common::frob_machine; // client helpers generated automatically use easy_jsonrpc_mw::ArgSerializeError; use easy_jsonrpc_mw::BoundMethod; use easy_jsonrpc_mw::Response; use serde::Deserialize; use std::convert::TryInto; use s...
true
3bdcdb0bde4b1d2020a327747eecbcd2cb3bb1d5
Rust
sria91-rlox/yaliir
/interpreter/src/expression.rs
UTF-8
3,129
3.359375
3
[ "MIT" ]
permissive
use crate::object::Object; use crate::token::Token; #[derive(Clone, Debug)] pub enum Expr { Assign { name: Token, value: Box<Expr>, }, Binary { left: Box<Expr>, operator: Token, right: Box<Expr>, }, Call { callee: Box<Expr>, paren: Token, ...
true
3df77602294daf084fa8938e12e85d45d1d444d9
Rust
mrmanne/advent-of-code-2020
/src/days/day4.rs
UTF-8
7,562
3.046875
3
[ "MIT" ]
permissive
use crate::puzzle::{io, File, Puzzle}; pub struct Day4; enum Field { BYR = 0, IYR = 1, EYR = 2, HGT = 3, HCL = 4, ECL = 5, PID = 6, CID = 7, } fn is_year_valid(value: &str, min: usize, max: usize) -> bool { if let Ok(year) = value.parse::<usize>() { if year >= min && year <...
true
0bf6e3f5b390c02fff9a3baecf922a3936ab8e2e
Rust
indutny/qcd
/src/complex.rs
UTF-8
3,048
3.9375
4
[]
no_license
use std::default::Default; use std::ops::{Add, Div, Mul, Sub}; #[derive(Copy, Clone, Debug, PartialEq)] pub struct Complex { pub re: f64, pub im: f64, } impl Complex { pub fn new(re: f64, im: f64) -> Self { Self { re, im } } pub fn norm_sqr(self: Self) -> f64 { self.re * self.re +...
true
582cfac48b90b5c539645d2aede2f433da7dfc69
Rust
2892931976/leetcode-rust
/examples/q84.rs
UTF-8
1,196
3.359375
3
[]
no_license
// https://leetcode-cn.com/problems/largest-rectangle-in-histogram/ // 给定 n 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。 // // 求在该柱状图中,能够勾勒出来的矩形的最大面积。 pub struct Solution {} impl Solution { pub fn largest_rectangle_area(heights: Vec<i32>) -> i32 { let mut stack: Vec<i32> = Vec::new(); let mut result =...
true
6dbf4318b3fae59e945d13d237276f38951f5c50
Rust
phansch/rust-clippy
/clippy_lints/src/non_copy_const.rs
UTF-8
20,685
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
//! Checks for uses of const which the type is not `Freeze` (`Cell`-free). //! //! This lint is **warn** by default. use std::ptr; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::in_constant; use if_chain::if_chain; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::...
true
ac9026acc98d9b7bfa1b8fe1557979f88e1a45e0
Rust
forestaa/troll
/src/domain/entry_factory.rs
UTF-8
13,359
2.9375
3
[]
no_license
use super::global_variable::*; use super::type_entry::*; use super::variable_declaration_entry::*; use crate::library::dwarf::{DwarfInfo, DwarfTag}; pub struct EntryFactory; pub enum FromDwarfInfoOutput { None, GlobalVariable(GlobalVariable), TypeEntry { entry: TypeEntry, children_warnings...
true