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
c6076b7cc290f151dd4c1f8ca10eb8a056e78944
Rust
stijnh/rust-advent-of-code-2020
/src/day01.rs
UTF-8
1,902
3.578125
4
[]
no_license
use crate::common::*; use std::cmp::Ordering::*; fn parse_input(filename: &str) -> Result<Vec<usize>> { let mut numbers = read_input(filename)? .into_iter() .filter(|x| !x.is_empty()) .map(|x| x.parse().context("invalid number")) .collect::<Result<Vec<_>, _>>()?; numbers.sort_u...
true
a76268466b84be62bf18fbd77c8e3ed5c23ceb9b
Rust
drklee3/vlive-rs
/src/model/helpers.rs
UTF-8
1,106
2.765625
3
[ "MIT" ]
permissive
use chrono::{offset::FixedOffset, DateTime}; use serde::{de, Deserialize, Deserializer}; pub fn bool_from_str<'de, D>(deserializer: D) -> Result<bool, D::Error> where D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; Ok(s == "Y") } pub fn timestamp_from_str<'de, D>(deserializer: D) -> Re...
true
d5f528b36df3b854797fbd27baca31ec9991a746
Rust
rust-lang-ja/rust-by-example-ja
/src-old/hello/print/fmt/show.rs
UTF-8
1,424
3.921875
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fmt::{self, Formatter, Display}; struct City { name: &'static str, // 緯度 lat: f32, // 経度 lon: f32, } impl Display for City { // `f` はバッファです。このメソッドは // ここにフォーマットされた文字列を書き込みます。 fn fmt(&self, f: &mut Formatter) -> fmt::Result { let lat_c = if self.lat >= 0.0 { 'N' } else ...
true
1e5906d69fd4d92d8a6c1509cf118df8a023b0f2
Rust
yoanlcq/lab
/rust/color_stds/src/css.rs
UTF-8
22,157
2.53125
3
[]
no_license
//! https://developer.mozilla.org/en-US/docs/Web/CSS/color_value use Rgb24; #[cfg(any(feature="tables", feature="css_table"))] use Entry; #[cfg(any(feature="tables", feature="css_table"))] pub const CSS_COLORS : &[Entry] = &[ Entry { ident: "black", value: hex24!(0x000000 ) }, Entry { ident: "silver", value:...
true
439bdd5ae06943a65f7c32661a5ad9c9f95b5fe7
Rust
dante-signal31/steganer
/src/argparser.rs
UTF-8
1,651
2.890625
3
[ "BSD-3-Clause" ]
permissive
use clap::{Arg, App}; use crate::configuration::Configuration; fn get_version()-> String { format!("{}.{}.{}{}", env!("CARGO_PKG_VERSION_MAJOR"), env!("CARGO_PKG_VERSION_MINOR"), env!("CARGO_PKG_VERSION_PATCH"), option_env!("CARGO_PKG_VERSION_PRE").unwrap_or("")) } ...
true
7350b5f490b35f3ebde9385611bd0f998780f31d
Rust
kaeluka/giftr
/src/refs/functional.rs
UTF-8
1,285
3.265625
3
[ "MIT" ]
permissive
use refs::GiftRef; use std::ops::{Deref,DerefMut}; use std::rc::Rc; #[derive(Debug)] pub struct Ref<T> { pub _ptr : Rc<T>, //public for the purpose of implementing `Drop` } impl <T> Ref<T> { fn rd<'a>(&'a self) -> &'a T { &*self._ptr } } impl <'c, T: Clone> GiftRef<T> for Ref<T> { #[inline] ...
true
ddc7ba496b82aad368394efb6e0e6793b9e77251
Rust
jeffrey-xiao/probabilistic-collections-rs
/src/similarity/mod.rs
UTF-8
3,575
3.734375
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Locality-sensitive hashing schemes for measuring similarities between sets. mod min_hash; mod sim_hash; pub use self::min_hash::MinHash; pub use self::sim_hash::SimHash; use std::collections::HashSet; use std::hash::Hash; use std::iter::FromIterator; /// A w-shingle iterator for an list of items. /// /// # Exam...
true
236cc36798f88210e56fd2b074d2fe58ac965fa7
Rust
ywzjackal/bp.rs
/tests/xor.rs
UTF-8
935
2.796875
3
[]
no_license
extern crate bp; extern crate serde_json; use bp::*; #[test] fn xor_4layers() { // create examples of the xor function let input = vec![vec![0.0, 0.0], vec![0.0, 1.0], vec![1.0, 0.0], vec![1.0, 1.0]]; let output = vec![vec![0.0], vec![1.0], vec![1.0], vec![0.0]]; // create a new neural network let...
true
d6495c1ce2e51154b05151f11a9afdd7ed36d46b
Rust
Latias94/rust-practice
/leetcode/src/s0350_intersection_of_two_arrays_ii.rs
UTF-8
1,282
3.359375
3
[ "MIT" ]
permissive
struct Solution; //leetcode submit region begin(Prohibit modification and deletion) use std::collections::HashMap; impl Solution { pub fn intersect(nums1: Vec<i32>, nums2: Vec<i32>) -> Vec<i32> { if nums1.len() > nums2.len() { return Self::intersect(nums2, nums1); } let mut int...
true
a352d57ede81cc718d756072fd0d73fb2c31ed20
Rust
bolucat/Archive
/trojanrust/src/main.rs
UTF-8
1,880
2.5625
3
[ "MIT" ]
permissive
use clap::Arg; use clap::{ArgMatches, Command}; use lazy_static::lazy_static; use log::info; use std::io::Result; use trojan_rust::config::base::{InboundConfig, InboundMode, OutboundConfig}; use trojan_rust::config::parser::read_config; use trojan_rust::proxy::grpc; use trojan_rust::proxy::quic; use trojan_rust::proxy:...
true
ac31cc03d565226923dc66f31e655c6b58f70c2c
Rust
x4e/scribe
/src/buffer/operation/history.rs
UTF-8
7,380
3.828125
4
[ "MIT" ]
permissive
use buffer::operation::Operation; /// Tracks a series of operations. /// /// Represents a linear history that can be traversed backwards and forwards. /// Adding a new operation to the history will clear any previously reversed /// operations, which would otherwise have been eligible to be redone. pub struct History {...
true
080fb9922af7ca66180941f190c285e2f7c27459
Rust
erikbgithub/FactorishWasm
/src/water_well.rs
UTF-8
7,111
2.625
3
[ "MIT" ]
permissive
use super::pipe::Pipe; use super::structure::{DynIterMut, Structure}; use super::{FactorishState, FrameProcResult, Position}; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use web_sys::CanvasRenderingContext2d; use std::cmp::Eq; #[derive(Eq, PartialEq, Clone, Copy, Debug, Serialize, Deserialize)]...
true
091aa08e4d8122d2662bf75fea62f85d6f37aaba
Rust
Mordeaux/RustyNails
/rust/rusty_nails/src/regression/mod.rs
UTF-8
127
2.859375
3
[ "Apache-2.0" ]
permissive
#[no_mangle] pub fn linear_regression(i: u32) -> u32 { println!("Hello World! {}", i); let x = i + 1; return x; }
true
a97b3a454355102ebc5abbd552a47c50d06725b5
Rust
romulocollopy/sesame
/src/tests/routes/api.rs
UTF-8
1,589
2.640625
3
[]
no_license
use crate::tests::setup; use axum::body::Body; use axum::http::{self, Request, StatusCode}; use serde_json::{json, Value}; use tower::ServiceExt; // for `app.oneshot()` #[tokio::test] async fn json_post() { let app = setup::build_test_app().await; let response = app .oneshot( Request::buil...
true
829481dc97e71f7555eb6abf512190fc7d394d66
Rust
sts10/advent-of-code-2018
/src/bin/my_slow_day05.rs
UTF-8
4,143
3.296875
3
[ "BlueOak-1.0.0" ]
permissive
use std::fs::File; use std::io; use std::io::prelude::*; fn main() { let test_polymer: String = "dabAcCaCBAcCcaDA".to_string(); let mut p_vec: Vec<char> = vec![]; for c in test_polymer.chars() { p_vec.push(c); } let mut p_vec: Vec<char> = read_string_from_file_to_vector("inputs/day05.txt").u...
true
e2a42f3a46f9476b68e43675fe53fdd3715685d1
Rust
EpicEric/rust-aoc-2020
/src/day9.rs
UTF-8
2,223
3.21875
3
[ "MIT" ]
permissive
use std::{ collections::{HashSet, VecDeque}, }; use regex::Regex; fn find_attack_number(preamble_size: usize) -> usize { let mut current_preamble: VecDeque<usize> = VecDeque::new(); let mut current_preamble_sums: VecDeque<Vec<usize>> = VecDeque::new(); for number in super::file::read_file("./in...
true
7c52e92361d6d6a84581b1673dd4751f1a4babdc
Rust
GildedHonour/TON-SDK
/ton_client/src/debot/adapter.rs
UTF-8
2,644
2.625
3
[ "Apache-2.0" ]
permissive
use super::action::DAction; use super::browser::BrowserCallbacks; use super::ParamsOfAppDebotBrowser; use super::ResultOfAppDebotBrowser; use crate::client::AppObject; use crate::crypto::KeyPair; pub(crate) struct DebotBrowserAdapter { app_object: AppObject<ParamsOfAppDebotBrowser, ResultOfAppDebotBrowser>, } imp...
true
42202e9d20a8093298a2321d32009f8cb3d3d117
Rust
nguyenminhhieu12041996/casper-node
/smart_contracts/contracts/test/ee-441-rng-state/src/main.rs
UTF-8
2,965
2.5625
3
[ "Apache-2.0" ]
permissive
#![no_std] #![no_main] extern crate alloc; use alloc::string::String; use casper_contract::{ contract_api::{runtime, storage}, unwrap_or_revert::UnwrapOrRevert, }; use casper_types::{ contracts::Parameters, CLType, CLValue, EntryPoint, EntryPointAccess, EntryPointType, EntryPoints, Key, RuntimeArgs, ...
true
5f893f1c5616a6c27f1a4bfb4a9c3fdc90134b8d
Rust
halhenke/git-global
/src/subcommands/prompt_cursive.rs
UTF-8
2,680
3.15625
3
[ "MIT" ]
permissive
extern crate cursive; use self::cursive::Cursive; // use cursive::views::{Dialog, TextView}; use self::cursive::align::HAlign; use self::cursive::event::EventResult; use self::cursive::traits::*; use self::cursive::views::{Dialog, OnEventView, SelectView, TextView}; use crate::models::errors::Result as WeirdResult; ...
true
6ea8ebd20065a53a0a323bd0ebcc7c5a72c827ed
Rust
markuskobler/rust-serde
/src/de.rs
UTF-8
25,326
3.3125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::hash::Hash; use std::marker::PhantomData; use std::num::FromPrimitive; use std::path; use std::str; /////////////////////////////////////////////////////////////////////////////// pub trait Error { fn syntax_error() -> Self; fn end_of_str...
true
c7d94c07d194a3aae3b96914e96e6d42796ac560
Rust
nushell/nushell
/crates/nu-cmd-extra/src/extra/bits/shift_left.rs
UTF-8
6,473
2.828125
3
[ "MIT" ]
permissive
use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, }; use num_tra...
true
722e9a44164c09ab3856465239af72d25df6d688
Rust
KurosPlayspace/codegame
/src/app/config_screen/player/tcp.rs
UTF-8
3,820
2.71875
3
[ "MIT" ]
permissive
use super::*; type TcpPlayerFuture<G> = dyn Future<Output = Result<TcpPlayer<G>, std::io::Error>>; pub struct TcpPlayerConfig<G: Game> { theme: Rc<ui::Theme>, options: TcpPlayerOptions, port_buttons: [ui::Button; 2], player: Option<Pin<Box<futures::future::MaybeDone<Pin<Box<TcpPlayerFuture<G>>>>>>>, }...
true
c2f824ae8d9d9c81f56180313efa2fc1b4d4a442
Rust
karjonas/advent-of-code
/2021/day07/src/lib.rs
UTF-8
1,483
3.34375
3
[]
no_license
extern crate common; fn solve_internal(input: &String, part_two: bool) -> usize { let numbers: Vec<usize> = input .split(",") .map(|v| common::string_to_usize(v)) .collect(); let min = numbers.iter().fold(0, |acc, x| std::cmp::min(acc, *x)); let max = numbers.iter().fold(0, |acc, x...
true
bbe43a32147219b1275bb863e91645dbd76061bb
Rust
6174/three-d
/src/core/buffer.rs
UTF-8
4,785
3.109375
3
[ "MIT" ]
permissive
use crate::core::Error; use crate::gl::Gl; use crate::gl::consts; pub struct VertexBuffer { gl: Gl, id: crate::gl::Buffer, count: usize } impl VertexBuffer { pub fn new_with_static_f32(gl: &Gl, data: &[f32]) -> Result<VertexBuffer, Error> { let id = gl.create_buffer().unwrap(); let...
true
362c3c2c5edd7aac93adb3bf9a9e69cac1a38577
Rust
tn47/ledger47
/src/cache.rs
UTF-8
4,105
2.625
3
[]
no_license
use llrb_index::Llrb; use std::ffi; use crate::{types, core::{Result, Transaction, Durable, Store}}; struct Cache<S> where S: Store { db: S, commodities: Llrb<String, types::Commodity>, companies: Llrb<String, types::Company>, ledgers: Llrb<String, types::Ledger>, entries: Llrb<String, types::Jo...
true
e05df6bbf8b21f82263bc820013fe89bc3d0d0e6
Rust
Byron/gitoxide
/gix-date/src/time/mod.rs
UTF-8
1,450
3.390625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::Time; /// Access impl Time { /// Return true if this time has been initialized to anything non-default, i.e. 0. pub fn is_set(&self) -> bool { *self != Self::default() } } /// Indicates if a number is positive or negative for use in [`Time`]. #[derive(PartialEq, Eq, Debug, Hash, Ord, Pa...
true
2b5c3c2f130422afb8582cf47a7f47b8909638c7
Rust
tanium/octobot
/ops/src/slack_db.rs
UTF-8
2,128
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anyhow::anyhow; use octobot_lib::db::{migrations, Connection, Database}; use octobot_lib::errors::*; use crate::slack_db_migrations; #[derive(Clone)] pub struct SlackDatabase { db: Database, } impl SlackDatabase { pub fn new(db_file: &str) -> Result<SlackDatabase> { let db = Database::new(db_file...
true
182366eed79f4e3b5ab7485135161bdf7573dc71
Rust
wxparr/rust
/src/Calculator.rs
UTF-8
2,984
3.96875
4
[]
no_license
#![allow(dead_code, unused_variables)] // make structs struct Data { num1: i32, num2: i32, str1: String, optional_num: Option<i32>, } struct TwoNums(i32, i32); struct Calculator; // implement methods on a struct impl Data { fn new() -> Self { Data { num1: 2, num2: ...
true
151fd3b00da6ffe5098dbebde90084fd0062db88
Rust
Dushistov/flapigen-rs
/python_tests/src/glue.rs.in
UTF-8
6,421
3.390625
3
[ "BSD-3-Clause" ]
permissive
use std::fmt; use std::sync::{Arc, Mutex}; pub enum TestEnum { A, B, } foreign_enum!( /// Test enum with A and B. enum TestEnum { A = TestEnum::A, B = TestEnum::B, } ); pub struct TestStaticClass {} impl TestStaticClass { pub fn hello() -> String { "Hello from rust".t...
true
cf2eecbb1b6817777688ef220fa1619111ad055e
Rust
iqlusioninc/sear
/src/bin/sear/command.rs
UTF-8
2,340
2.6875
3
[ "Apache-2.0" ]
permissive
//! `sear`: CLI option parser use crate::{config::SearConfig, error::Error, op::Op, prelude::*}; use abscissa_core::{command::Usage, Command, Configurable, Options, Runnable}; use std::{convert::TryFrom, path::PathBuf, process::exit}; /// sear command line option parser #[derive(Command, Debug, Options)] pub struct S...
true
6a1b7039ca1df52829818d8468161fc29c51abeb
Rust
jakeprobst/darkbridge
/src/items.rs
UTF-8
109,279
2.9375
3
[]
no_license
#![allow(unused_must_use)] #![allow(dead_code)] use std::convert::TryFrom; use regex::Regex; #[derive(Debug)] pub enum ItemParseError { MissingParameter, UnknownItem(String), UnknownSpecial(String), UnknownAttribute(String), UnknownTech(String), UnknownPhotonBlast(String), ParseIntError(s...
true
83ebf5b658b22589f0d841dbd3a850755407b898
Rust
ChosunOne/merkle_bit
/src/tree_hasher/keccak.rs
UTF-8
630
2.515625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use tiny_keccak::Hasher; use tiny_keccak::Keccak; use crate::Array; pub struct KeccakHasher(Keccak); impl<const N: usize> crate::traits::Hasher<N> for KeccakHasher { #[inline] fn new(_size: usize) -> Self { let hasher = Keccak::v256(); Self(hasher) } #[inline] fn update(&mut self...
true
f1886407fdbcb5e5e86c3472f82e90ca96974b8e
Rust
a-peyrard/rust-dojo
/src/challenge/max_profit.rs
UTF-8
736
3.71875
4
[]
no_license
use std::cmp; pub fn max_profit(prices: Vec<i32>) -> i32 { let mut profit = 0; let mut buy = i32::MAX; for price in prices { buy = cmp::min(buy, price); profit = cmp::max(profit, price - buy); } profit } #[cfg(test)] mod tests { use super::*; #[test] fn it_should_valid...
true
f11d2c3375d032b6facb221f1984725d7e1f964c
Rust
zed0/advent-of-code
/2021/src/bin/aoc-17/main.rs
UTF-8
3,657
3.171875
3
[]
no_license
use std::fs; use std::env; use std::str::FromStr; use std::time::SystemTime; use std::convert::TryInto; use std::convert::TryFrom; use std::convert::Infallible; use std::collections::HashMap; use std::collections::HashSet; use std::collections::BTreeSet; use std::cmp::min; use itertools::Itertools; use std::ops::{Add};...
true
0aa5633425c519c560cbf654610f4a2d60aaac95
Rust
Mange/mpris-rs
/examples/get_metadata.rs
UTF-8
955
2.640625
3
[ "Apache-2.0" ]
permissive
use anyhow::{Context, Result}; use mpris::PlayerFinder; fn main() { match print_metadata() { Ok(_) => {} Err(error) => { println!("Error: {}", error); for (i, cause) in error.chain().skip(1).enumerate() { print!("{}", " ".repeat(i + 1)); prin...
true
5d6325b395571a7688ed7345429e70242c6be986
Rust
straussdd/hunter
/src/trait_ext.rs
UTF-8
847
2.734375
3
[ "WTFPL" ]
permissive
use std::path::PathBuf; use crate::fail::{HResult, MimeError}; use crate::files::File; // This makes using short-circuiting iterators more convenient pub trait ExtractResult<T> { fn extract(self) -> T; } impl<T> ExtractResult<T> for Result<T,T> { fn extract(self) -> T { match self { ...
true
9a5fbeeaa9130bca7f7734b404a3448eab2bbd35
Rust
voidpumpkin/rusty-rougelike
/src/systems/item_drop_system.rs
UTF-8
1,741
2.578125
3
[ "MIT" ]
permissive
use crate::{ components::{InBackpack, Name, Position, WantsToDropItem}, gamelog::GameLog, }; use specs::{ prelude::{ReadExpect, ReadStorage, System, WriteExpect, WriteStorage}, Entities, Entity, Join, }; pub struct ItemDropSystem {} impl<'a> System<'a> for ItemDropSystem { type SystemData = ( ...
true
476921debcef0fa9c158fbc6b5ac2891dbda9f8b
Rust
quangtung97-study/20191-software-economics-version2
/src/newton.rs
UTF-8
2,712
3.28125
3
[]
no_license
use ndarray::{Array1, Array2}; use ndarray_linalg::Solve; const N: usize = 10; #[allow(dead_code)] pub fn simple_newton_method(f: impl Fn(f64) -> f64, df: impl Fn(f64) -> f64, x0: f64) -> f64 { let mut x = x0; for _ in 0..N { x = x - f(x) / df(x); } return x; } pub fn jacobi( f: &impl Fn(...
true
e4f9ad196c9315561b80143882aa9741e8a1a5d3
Rust
rust-lang/cargo
/src/cargo/core/compiler/custom_build.rs
UTF-8
48,801
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-only", "Apache-2.0", "MIT", "GCC-exception-2.0", "BSD-3-Clause", "LGPL-2.0-or-later", "Zlib", "OpenSSL", "curl", "LGPL-2.1-only", "BSD-2-Clause", "LicenseRef-scancode-ssleay-windows", "Unlicense" ]
permissive
//! How to execute a build script and parse its output. //! //! ## Preparing a build script run //! //! A [build script] is an optional Rust script Cargo will run before building //! your package. As of this writing, two kinds of special [`Unit`]s will be //! constructed when there is a build script in a package. //! /...
true
b9b4d1a0bbf603b1b4a79638285c2b9a9000c2f4
Rust
lelongg/adskalman-rs
/src/lib.rs
UTF-8
19,464
2.609375
3
[ "MIT", "Apache-2.0" ]
permissive
#![cfg_attr(not(feature = "std"), no_std)] //! Kalman filter and Rauch-Tung-Striebel smoothing implementation //! //! Characteristics: //! - Uses the [nalgebra](https://nalgebra.org) crate for math. //! - Supports `no_std` to facilitate running on embedded microcontrollers. //! - Includes [various methods of computing ...
true
f7de1ccf4e9935b3bb50c87ccf09665e202cddd7
Rust
R1tschY/avrvc
/src/tools/objdump.rs
UTF-8
5,940
2.828125
3
[]
no_license
use instruction_set::Instruction; use decoder::AvrDecoder; use decoder::Decoder; use instruction_set::RegIncDec; pub trait ObjDumpInstr { fn dump(&self) -> String; } fn format_calljmp(mnemonic: &str, k: u32) -> String { if k == 0 { format!("{}\t0", mnemonic) } else { format!("{}\t0x{:x}",...
true
e60b72b6b164d1cdde7af74e513fa4cff43b0005
Rust
pimpale/bplus
/src/astbuilder.rs
UTF-8
19,585
2.828125
3
[]
no_license
use super::ast::{BinaryOpKind, Expr, ExprKind, Metadata}; use super::codereader::union_of; use super::dlogger::DiagnosticLogger; use super::token::{Token, TokenKind}; use lsp_types::Range; use peekmore::{PeekMore, PeekMoreIterator}; // clobbers the cursor fn peek_past_metadata<TkIter: Iterator<Item = Token>>( tkiter...
true
0048da2931b9f517afe47638367f5a0ce78c7f79
Rust
phial3/mysql_cdc
/src/binlog_options.rs
UTF-8
3,074
2.84375
3
[ "MIT" ]
permissive
use crate::constants::FIRST_EVENT_POSITION; use crate::providers::mariadb::gtid::gtid_list::GtidList; use crate::providers::mysql::gtid::gtid_set::GtidSet; use crate::starting_strategy::StartingStrategy; /// Replication options used when client connects to the server. #[derive(Debug)] pub struct BinlogOptions { //...
true
eb7f9fd574708f79b0688d255267e060247f6d64
Rust
Logicalshift/safas
/src/syntax/def_syntax.rs
UTF-8
18,602
2.6875
3
[ "Apache-2.0" ]
permissive
use super::syntax_symbol::*; use super::syntax_closure::*; use super::pattern_match::*; use crate::bind::*; use crate::meta::*; use itertools::*; use std::sync::*; use std::collections::{HashMap}; use std::convert::*; /// /// Given a partially parsed set of macro definitions, binds them and generates a full syntax c...
true
6e25a381e976ce79cd1d4b9f1cb86a53e6b7e3c4
Rust
str4d/rage
/age/src/lib.rs
UTF-8
10,279
3.46875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! *Library for encrypting and decrypting age files* //! //! This crate implements file encryption according to the [age-encryption.org/v1] //! specification. It generates and consumes encrypted files that are compatible with the //! [rage] CLI tool, as well as the reference [Go] implementation. //! //! The encryption...
true
a4d092811899de7daa19fae5146f6666064a0117
Rust
sgmarz/raytrace
/src/texture.rs
UTF-8
3,995
2.953125
3
[ "MIT" ]
permissive
// texture.rs // Texturing functions // Stephen Marz // 15 Dec 2020 use crate::perlin::Perlin; use crate::vector::{Color, Vec3}; use std::fs::File; use std::sync::Arc; pub trait Texture { fn value(&self, u: f64, v: f64, point: &Vec3) -> Color; } // TEXTURES // Solid color #[derive(Default)] pub struct SolidColor {...
true
72b80fef6699f74e135ddb424b504610efff9b49
Rust
sarum9in/lab_voice_classifier
/src/sound.rs
UTF-8
1,600
2.984375
3
[]
no_license
use std::path; use std::vec::Vec; extern crate hound; extern crate rand; pub struct MonoSound { pub data: Vec<Vec<i16>> } impl MonoSound { pub fn new() -> MonoSound { MonoSound { data: Vec::new() } } pub fn read(file: &path::Path, sample_window: usize) -> MonoSound { ...
true
41cb9fa71968f8a71c4df7f709771f7967c84150
Rust
sugyan/atcoder
/arc002/src/bin/b.rs
UTF-8
723
2.53125
3
[]
no_license
use proconio::{fastout, input}; #[fastout] fn main() { input! { s: String, } let ymd = s .split('/') .filter_map(|s| s.parse::<usize>().ok()) .collect::<Vec<_>>(); let (mut y, mut m, mut d) = (ymd[0], ymd[1], ymd[2]); let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 3...
true
67fc320a3d248ac16772153339ed2a093a5e2326
Rust
reb/advent_of_code_2019
/src/intcode.rs
UTF-8
22,573
2.921875
3
[]
no_license
#[cfg(test)] use mockall::automock; use std::collections::HashMap; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] enum Mode { Position, Immediate, Relative, } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)] pub enum ExitStatus { Finished, WaitingForInput(i64, i64), } pub type Program = ...
true
a9007129d0401b608ea74dbea638a55910b5b9d6
Rust
JPRoland/tetrs
/src/game.rs
UTF-8
4,043
2.703125
3
[]
no_license
use std::time::SystemTime; use crate::tetromino::{self, Tetromino, TetrominoGenerator}; pub const LEVEL_TIMES: [u32; 10] = [1000, 850, 700, 600, 500, 400, 300, 250, 221, 190]; pub const LEVEL_LINES: [u32; 10] = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200]; pub struct Game { pub game_map: Vec<Vec<u8>>, pub ...
true
b10a287e9314b9b45eb6ccea96bef0991b6f3f5c
Rust
Punie/Rocket
/core/lib/src/ext.rs
UTF-8
3,338
2.8125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::io; use std::pin::Pin; use std::task::{Poll, Context}; use futures::{ready, stream::Stream}; use tokio::io::{AsyncRead, ReadBuf}; use pin_project_lite::pin_project; use crate::http::hyper::Bytes; pub struct IntoBytesStream<R> { inner: R, buf_size: usize, buffer: Vec<u8>, } impl<R> Stream for In...
true
2ea5f5cfa5024bbfb4fdacb0b8f4eb7d01cd5038
Rust
happysalada/nix-cargo-integration
/cli/src/main.rs
UTF-8
3,750
2.84375
3
[ "MIT" ]
permissive
use std::{env::var, fs, io, path::Path}; const NCI_SRC: Option<&str> = option_env!("NCI_SRC"); const HELP: &str = r#" show <source url> -> run `nix flake show` the specified source build <source url> <package: default package> -> builds a package (defaults to the default package) in the specified source run <source ur...
true
4bc2eb3bccc54393b94fddc7bde3113eab6c9d86
Rust
RustyYato/storage
/storage/src/bump.rs
UTF-8
9,182
2.890625
3
[]
no_license
use core::{ alloc::Layout, num::NonZeroUsize, ptr::NonNull, sync::atomic::{AtomicUsize, Ordering}, }; use crate::{ AllocErr, FromPtr, Handle, MemoryBlock, MultiStorage, NonEmptyLayout, NonEmptyMemoryBlock, OffsetHandle, ResizableStorage, SharedGetMut, SharedOffsetHandle, SharedResizableStorage,...
true
966eb378773f13e8d3505a24c09e1987885186c5
Rust
huggingface/tokenizers
/tokenizers/src/normalizers/replace.rs
UTF-8
4,653
3.40625
3
[ "Apache-2.0" ]
permissive
use crate::tokenizer::pattern::Pattern; use crate::tokenizer::Decoder; use crate::tokenizer::{NormalizedString, Normalizer, Result}; use crate::utils::SysRegex; use serde::{Deserialize, Serialize}; /// Represents the different patterns that `Replace` can use #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq...
true
e1fd741d73562edff9c620a334db0fd333925e5c
Rust
cozydate/rust-in-production
/http/src/bin/concurrent_connections.rs
UTF-8
3,717
3.09375
3
[ "MIT" ]
permissive
// This program shows how to handle multiple connections at the same time. use std::println; use tokio::net::{TcpListener, TcpStream}; async fn handle_conn(mut tcp_stream: TcpStream) { let addr = tcp_stream.peer_addr().unwrap(); use tokio::io::AsyncReadExt; let mut buf = String::new(); if let Err(e) =...
true
843ad56837cd9d3a42b20afb2ec98a3e69d316e9
Rust
rust-lang/stdarch
/crates/core_arch/src/x86_64/bt.rs
UTF-8
3,799
2.796875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::arch::asm; #[cfg(test)] use stdarch_test::assert_instr; // x32 wants to use a 32-bit address size, but asm! defaults to using the full // register name (e.g. rax). We have to explicitly override the placeholder to // use the 32-bit register name in that case. #[cfg(target_pointer_width = "32")] macro_rules!...
true
15dd1720b092011a641926a10de0d8f3aa223203
Rust
chlobes/voxel_rogue_lib
/src/entity.rs
UTF-8
1,817
3.046875
3
[]
no_license
use crate::prelude::*; use crate::item::Item; #[derive(Debug,Clone,Serialize,Deserialize)] pub struct Entity { pub id: u64, pub typ: EntityType, pub pos: Vec3<f64>, pub hp: Option<(f64, f64)>, pub properties: HashMap<String, String>, } impl Entity { pub fn detailed_info(&self) -> String { let mut r = format!(...
true
6cc4e64e1783a3debcfb048f25508a3973f55a72
Rust
Axect/Rust
/Library/cursive_tut/src/bin/tut_3.rs
UTF-8
2,026
2.984375
3
[]
no_license
extern crate cursive; use cursive::{ Cursive, views::{Button, Dialog, DummyView, EditView, LinearLayout, SelectView}, traits::*, }; fn main() { let mut siv = Cursive::default(); let select = SelectView::<String>::new() .on_submit(on_submit) .with_name("select") .fixed_size...
true
1d2c5744bafac00650cea85dc35bb28fbd53af6c
Rust
rfdonnelly/lfsr-parallel
/rust/src/lib.rs
UTF-8
6,320
3.25
3
[]
no_license
use std::fmt; use std::collections::HashSet; #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] enum Variable { InitialState, Data, } #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] struct Term { variable: Variable, index: usize, } #[derive(Clone)] pub struct Terms { terms:...
true
743ea0f770d9e0d38dec8c1b85bfb353dc31b201
Rust
pombredanne/symbolic
/symbolic-cabi/src/unreal.rs
UTF-8
3,495
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::os::raw::c_char; use std::slice; use symbolic::unreal::{Unreal4Crash, Unreal4File}; use crate::core::SymbolicStr; use crate::utils::ForeignObject; /// An Unreal Engine 4 crash report. pub struct SymbolicUnreal4Crash; impl ForeignObject for SymbolicUnreal4Crash { type RustObject = Unreal4Crash; } /// A...
true
5462f55389ce453afcd3b0f34538e32a8bba7c30
Rust
gnoliyil/fuchsia
/src/connectivity/network/lib/explicit/src/lib.rs
UTF-8
1,416
2.8125
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Utilities which allow code to be more robust to changes in dependencies. //! //! The utilities in this crate allow code to depend on details of its //!...
true
7cdb4940443e0b58f8e5097da0bb241ddf089e7c
Rust
kokizzu/kokizzu-benchmark
/prime/prime.rs
UTF-8
444
2.53125
3
[]
no_license
fn main() { let mut last : i32 = 3; let mut res = vec![last]; loop { last += 2; let mut prime = true; for v in res.iter() { if *v * *v > last { break; } if (last % *v) == 0 { prime = false; break; } } if prime { res.push(last); if re...
true
dc28c4c7612ceb844c5e11d155caac0a0c3a357f
Rust
gliderkite/akkorokamui
/src/client/builder.rs
UTF-8
2,201
2.9375
3
[ "MIT" ]
permissive
use std::{convert::TryInto, fmt}; use crate::{ client::{blocking, Client}, Credentials, Error, Result, }; /// Client builder. pub struct ClientBuilder { /// The User-Agent header used for each request. user_agent: String, /// The credentials to use for private APIs. credentials: Option<Credent...
true
d546f1fcbad5ebff1868ba64cf150c874dc12e13
Rust
ModProg/witchbox2
/src/display/channel.rs
UTF-8
2,312
2.8125
3
[]
no_license
use std::collections::VecDeque; use tinybit::{Pixel, Renderer, ScreenPos, ScreenSize, StdoutTarget, Viewport}; use super::animation::{Anim, Animation}; use crate::twitch::Twitch; pub struct ChannelEvents { viewport: Viewport, animation_queue: VecDeque<(Anim, Twitch)>, current: Option<(Anim, Twitch)>, ...
true
366b6465d4d5557ab527107474522b9902afde79
Rust
MikhailKravets/NeuroFlow
/src/io/mod.rs
UTF-8
2,493
3.640625
4
[ "MIT" ]
permissive
//! The module contains functions, structs, enums, and traits //! for input/output neural networks. E. g. it can save network //! to the file and then loads it back. //! //! # Example //! Saving of neural network: //! //! ```rust //! use neuroflow::FeedForward; //! use neuroflow::io; //! //! let mut nn = FeedForward::n...
true
aa552eaf8114042b0e23d1db4c6fe8db3f0c68a3
Rust
chinanf-boy/gentle-intro
/code/ref1.rs
UTF-8
193
3.328125
3
[ "MIT" ]
permissive
// ref1.rs fn main() { let s1 = "hello dolly".to_string(); let mut rs1 = &s1; { let tmp = "hello world".to_string(); rs1 = &tmp; } println!("ref {}",rs1); }
true
895e5a3ec6ceb890fe1677e937e480abc4649384
Rust
jcsims/aoc2020
/src/day6.rs
UTF-8
982
3.09375
3
[]
no_license
use crate::util; use std::collections::HashSet; pub fn part1() -> i64 { let forms = util::squash_stanzas("data/d6.txt"); forms.iter().map(|form| one_yes(form)).sum() } pub fn part2() -> i64 { let forms = util::squash_stanzas("data/d6.txt"); forms.iter().map(|form| all_yes(form)).sum() } fn one_yes(...
true
fb54576b270d4d41f087d5bebb570a195292df77
Rust
thebitfarm/Exercism
/rust/etl/src/lib.rs
UTF-8
346
2.765625
3
[]
no_license
use std::collections::BTreeMap; pub fn transform(h: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> { let mut ret_map = BTreeMap::<char, i32>::new(); h.iter().for_each( |(k, v)| { v.iter().flat_map(|&c| c.to_lowercase()).for_each(|c| { ret_map.entry(c).or_insert(*k); }); ...
true
3e631d56c647ca261b166fdeeeab40169905549b
Rust
barnex/brilliance-ray-tracer
/brilliance/src/tracer/lights/with_object.rs
UTF-8
674
2.90625
3
[]
no_license
use super::*; pub struct WithObject<L: Light, O: Object> { light: L, // TODO: this should be a trait? object: O, } impl<L: Light, O: Object> WithObject<L, O> { pub fn new(light: L, object: O) -> Self { Self { light, object } } } impl<L: Light, O: Object> Bounded for WithObject<L, O> { fn bounds(&self) -> Boun...
true
448c5186c7b6c92cece088425c8b28474d4deb41
Rust
rust-skia/rust-skia
/skia-safe/src/interop/stream.rs
UTF-8
14,183
2.546875
3
[ "MIT" ]
permissive
//! `SkStream` and relatives. //! This implementation covers the minimal subset to interface with Rust streams. //! //! Bindings that wrap functions that use Skia stream types _must_ use Rust streams instead. use crate::{prelude::*, Data}; use skia_bindings::{ self as sb, SkDynamicMemoryWStream, SkMemoryStream, Sk...
true
e9403f659cf8308b35d4e66e42e863a20e2be8f8
Rust
GaloisInc/mir-verifier
/lib/compiler-builtins/src/int/mul.rs
UTF-8
3,606
2.875
3
[ "NCSA", "MIT" ]
permissive
use core::ops; use int::Int; use int::LargeInt; trait Mul: LargeInt { fn mul(self, other: Self) -> Self { let half_bits = Self::BITS / 4; let lower_mask = !<<Self as LargeInt>::LowHalf>::ZERO >> half_bits; let mut low = (self.low() & lower_mask).wrapping_mul(other.low() & lower_mask); ...
true
bb1c811ad770fc4df1d48a5dd93110d0d84ee47e
Rust
grantlemons/neo4rs
/lib/src/messages/success.rs
UTF-8
1,119
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::types::*; use neo4rs_macros::BoltStruct; #[derive(Debug, PartialEq, Clone, BoltStruct)] #[signature(0xB1, 0x70)] pub struct Success { metadata: BoltMap, } impl Success { pub fn get<T: std::convert::TryFrom<BoltType>>(&self, key: &str) -> Option<T> { self.metadata.get(key) } } #[cfg(tes...
true
4595b0e06a34b515d72498d76dff12a4b7f6d927
Rust
jessica-taylor/mercatoria_rust
/src/account_transform.rs
UTF-8
12,600
2.640625
3
[ "MIT" ]
permissive
//! Functionality for modifying accounts according to actions. use std::{collections::BTreeMap, marker::PhantomData}; use anyhow::bail; use async_trait::*; use ed25519_dalek::Signer; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::blockdata::{Action, MainBlock, SendInfo}; use crate::crypto::{has...
true
26a9862ec5e23144ad8f3a93e67b8ab7140fa840
Rust
zhaoshenglong/Leetcode
/dynamic_programming_practice/509_easy_fibonacci_number.rs
UTF-8
391
3.09375
3
[]
no_license
struct Solution; impl Solution { pub fn fib(n: i32) -> i32 { if n <= 1 { return n; } let mut prev = 1; let mut pprev = 0; let mut cur = 0; for i in 2..n + 1 { cur = prev + pprev; pprev = prev; prev = cur; } ...
true
5de7a9a013de4a0563e9a501c3049b669e394cc0
Rust
frewsxcv/rust-crates-index
/src/dedupe.rs
UTF-8
2,462
2.96875
3
[ "Apache-2.0" ]
permissive
use crate::Dependency; use rustc_hash::FxHashSet; use std::collections::HashMap; use std::hash::Hash; use std::hash::Hasher; use std::sync::Arc; /// Many crates (their versions) have the same features and dependencies pub(crate) struct DedupeContext { features: FxHashSet<HashableHashMap<String, Vec<String>>>, ...
true
5436f1b39dd826e56869f37ce55968259f5a8875
Rust
clchiou/garage
/rust/g1/tokio/src/bstream/codec.rs
UTF-8
11,077
3
3
[ "MIT" ]
permissive
use std::pin::Pin; use std::task::{Context, Poll}; use async_trait::async_trait; use bytes::BytesMut; // We use `futures::stream::Stream` because `std::async_iter::AsyncIterator` (previously known as // `std::stream::Stream`) is still a bare-bones implementation - it does not even have an // `async fn next` method! us...
true
4ca74000416442c340d3812feca847dea983a6ce
Rust
afpatmin/dungeons
/src/states/game.rs
UTF-8
2,388
2.671875
3
[]
no_license
pub const CAMERA_WIDTH: f32 = 1500.0; pub const CAMERA_HEIGHT: f32 = 1500.0; use amethyst::{ assets::{AssetStorage, Handle, Loader}, core::transform::Transform, prelude::*, renderer::{Camera, ImageFormat, SpriteRender, SpriteSheet, SpriteSheetFormat, Texture}, }; use crate::components::{ParticleGenera...
true
fbbf2707ad5d23e4fdeb42771bc03aac8364b714
Rust
swift-school/google-cloud-rs
/google-cloud/src/storage/client.rs
UTF-8
4,888
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::env; use std::fs::File; use std::sync::Arc; use json::json; use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC}; use tokio::sync::Mutex; use crate::authorize::{ApplicationCredentials, TokenManager}; use crate::storage::api::bucket::{BucketResource, BucketResources}; use crate::storage::{Bucket, Err...
true
2a6e118b2b71612b04bfdbfcb0383b979b0534fa
Rust
miscreant/miscreant.rs
/src/aead.rs
UTF-8
6,143
3.109375
3
[ "MIT", "Apache-2.0" ]
permissive
//! `aead.rs`: Authenticated Encryption with Associated Data (AEAD): //! Symmetric encryption which ensures message confidentiality, integrity, //! and authenticity. use crate::{ generic_array::{typenum::U16, ArrayLength, GenericArray}, Error, }; use aes::{Aes128, Aes256}; use aes_siv::siv::{Siv, IV_SIZE}; use...
true
f125607cd20dda0d3da263023310684f9b78bd2b
Rust
bobbin-rs/bobbin-sdk
/mcu/bobbin-stm32/stm32-common/src/iwdg.rs
UTF-8
12,173
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
#[derive(Clone, Copy, PartialEq, Eq)] #[doc="IWDG Peripheral"] pub struct IwdgPeriph(pub usize); impl IwdgPeriph { #[doc="Get the KR Register."] #[inline] pub fn kr_reg(&self) -> ::bobbin_mcu::register::Register<Kr> { ::bobbin_mcu::register::Register::new(self.0 as *mut Kr, 0x0) } #[doc="Ge...
true
9d3acd29202ef022e02ab73fdd7c657935c9d21c
Rust
rust-lang/rust-analyzer
/crates/ide/src/goto_type_definition.rs
UTF-8
7,678
2.625
3
[ "Apache-2.0", "MIT" ]
permissive
use ide_db::{base_db::Upcast, defs::Definition, helpers::pick_best_token, RootDatabase}; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, T}; use crate::{FilePosition, NavigationTarget, RangeInfo, TryToNav}; // Feature: Go to Type Definition // // Navigates to the type of an identifier. // // |=== //...
true
2ef4efdd758bd503a75cdd16c114165e8b056c08
Rust
ennocramer/lucifer
/src/lighting/blackbody.rs
UTF-8
578
3.078125
3
[]
no_license
use geometry::Intersection; use lighting::{Bsdf, Distribution, Effect, Material, Radiance}; /// A pure emitter of light. #[derive(Clone, Debug)] pub struct Blackbody { pub radiance: Radiance, } impl Blackbody { /// Creates a new `Blackbody` material. pub fn new(radiance: Radiance) -> Self { Blackb...
true
f5f7531ca4d81e96c83f26ce3631dcd1faee0837
Rust
a186r/rust-evm
/add/adder/src/main.rs
UTF-8
382
3.15625
3
[]
no_license
use add_one; use rand; use crate::List::{Cons, Nil}; enum List{ Cons(i32, Box<List>), Nil, } fn main() { // println!("Hello, world!"); let num = 10; println!("Hello, world! {} plus one is {}", num, add_one::add_one(num)); let b = Box::new("hello"); println!("b = {}", b); let list = Co...
true
e7cfebb00a7a18a3d3c5eb74094a4b6847302610
Rust
quartiq/stabilizer
/src/hardware/dac.rs
UTF-8
11,907
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Stabilizer DAC management interface //! //! # Design //! //! Stabilizer DACs are connected to the MCU via a simplex, SPI-compatible interface. Each DAC //! accepts a 16-bit output code. //! //! In order to maximize CPU processing time, the DAC code updates are offloaded to hardware using //! a timer compare channel...
true
cc438db176a818864fa672139496a162942fe520
Rust
himlpplm/rust-tdlib
/src/types/set_chat_location.rs
UTF-8
2,269
2.984375
3
[ "MIT" ]
permissive
use crate::errors::*; use crate::types::*; use uuid::Uuid; /// Changes the location of a chat. Available only for some location-based supergroups, use supergroupFullInfo.can_set_location to check whether the method is allowed to use #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct SetChatLocation { ...
true
9389d9532edcf2b6e17f127f17a9f3a039d94bdc
Rust
alishahusain/lpd
/rpc/client/src/lightning_address.rs
UTF-8
1,119
3.125
3
[ "Apache-2.0" ]
permissive
use std::net::SocketAddr; use std::str::FromStr; use dependencies::hex; // TODO(mkl): allow usage of domain names #[derive(Debug)] pub struct LightningAddress { pub pub_key: String, pub host: SocketAddr, } impl FromStr for LightningAddress { type Err = String; fn from_str(s: &str) -> Result<Self, Sel...
true
d1c839e329234d7d8f6987430ca8c5d04c445f84
Rust
z1queue/smartcore
/src/linalg/naive/dense_matrix.rs
UTF-8
39,516
2.890625
3
[ "Apache-2.0" ]
permissive
#![allow(clippy::ptr_arg)] use std::fmt; use std::fmt::Debug; #[cfg(feature = "serde")] use std::marker::PhantomData; use std::ops::Range; #[cfg(feature = "serde")] use serde::de::{Deserializer, MapAccess, SeqAccess, Visitor}; #[cfg(feature = "serde")] use serde::ser::{SerializeStruct, Serializer}; #[cfg(feature = "se...
true
ffa92d300145abd0108c7ebcd7102b270f994984
Rust
AlexJGood/AOC2018
/Day1/part1.rs
UTF-8
683
3.140625
3
[]
no_license
use std::{ env, fs::File, io::{prelude::*, BufReader}, path::Path, }; fn lines_from_file<P>(filename: P) -> Vec<String> where P: AsRef<Path>, { let file = File::open(filename).expect("no such file"); let buf = BufReader::new(file); buf.lines() .map(|l| l.expect("Could not parse ...
true
6337a0525dad282fbab13a8f4173b25932875a63
Rust
doytsujin/yew
/examples/todomvc/src/main.rs
UTF-8
8,586
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
use gloo::storage::{LocalStorage, Storage}; use state::{Entry, Filter, State}; use strum::IntoEnumIterator; use web_sys::HtmlInputElement as InputElement; use yew::events::{FocusEvent, KeyboardEvent}; use yew::html::Scope; use yew::{classes, html, Classes, Component, Context, Html, NodeRef, TargetCast}; mod state; co...
true
0fa92ad222b032398c5ad413d8dc00c6f1429b5e
Rust
actix/actix-website
/examples/errors/src/recommend_one.rs
UTF-8
1,059
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
// <recommend-one> use actix_web::{ error, get, http::{header::ContentType, StatusCode}, App, HttpResponse, HttpServer, }; use derive_more::{Display, Error}; #[derive(Debug, Display, Error)] enum UserError { #[display(fmt = "Validation error on field: {}", field)] ValidationError { field: String },...
true
865caa692a41870f039f668a9593bb08ead69f8a
Rust
HadrienG2/conv-tests
/src/lib.rs
UTF-8
24,460
2.703125
3
[]
no_license
#![feature(array_chunks)] #![feature(array_windows)] #![feature(portable_simd)] #![feature(trusted_len)] use core_simd::{LaneCount, Mask32, SimdF32, SupportedLaneCount}; use more_asserts::*; use paste::paste; use std::ops::AddAssign; // SIMD processing parameters pub type Scalar = f32; pub type Simd<const LANES: usiz...
true
454c80a279a190cec35e2fb44f969ea6701d2d74
Rust
dtolnay/gflags
/tests/print.rs
UTF-8
2,253
3.1875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use assert_cmd::Command; use predicates::prelude::*; use std::ffi::OsStr; #[test] fn no_flags() { let mut cmd = Command::cargo_bin("examples/print").unwrap(); cmd.assert().success(); } /// Helper function to test errors when passing invalid arguments. Runs the /// binary, passing `args`, expecting a failure t...
true
9c3553cab43ef01bda872ccf4f559cfb3c3a661d
Rust
shengLin-alex/rust-exercise
/closure/src/cacher/mod.rs
UTF-8
1,237
3.75
4
[]
no_license
use std::collections::HashMap; /// 定義一個可以存放閉包之物件 /// 為了實現緩存(cache) 的機制, 將 values 定義為 Option, /// 當 values 為 None 時, 執行閉包運算, 為 Some() 時即可直接取得數據 /// /// 因此便可以解決, 多次實際呼叫閉包進行耗時計算的資源浪費 pub struct Cacher<T> where T: Fn(u32) -> u32 { calculation: T, values: HashMap<u32, Option<u32>>, } impl<T> Cacher<T> where T: Fn...
true
380f33371437ef5725284646430cd658bc5d5fd7
Rust
Hirevo/alexandrie
/helpers/syntect-dump/src/main.rs
UTF-8
2,037
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::io::Write; use std::{fs, io}; use syntect::dumps; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSetBuilder; fn main() { println!(); print!("loading syntaxes from directory... "); io::stdout().flush().expect("could not flush stdout"); let syntaxes = { let mut builde...
true
fd4147c9fbc3d77ecd4b4ae257f950e2bb073651
Rust
swilcox3/rootsmagic-importer
/src/importers/mod.rs
UTF-8
2,318
2.578125
3
[ "MIT" ]
permissive
use crate::utils::*; pub mod wikitree; #[derive(Debug, Clone)] pub enum Gender { Unknown, Female, Male, Other, } #[derive(Debug)] pub struct Search { pub first_name: Option<String>, pub last_name: Option<String>, pub birth_date: Option<String>, pub death_date: Option<String>, pub ...
true
625020868c83fdb0530c3a3c3f2122bee3a78685
Rust
MasterScott/seclip
/src/main.rs
UTF-8
4,704
3.390625
3
[ "MIT" ]
permissive
use std::env; use std::process; use std::{thread, time}; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; use std::path::Path; use clap::{Arg, App}; use clipboard::ClipboardProvider; use clipboard::ClipboardContext; use colored::*; // function to set the value to clipboard fn copy_to_clipboard(va...
true
dc9763f69ba2c22d2daad65182c485615a00d70a
Rust
pierrechevalier83/unicode_types
/src/generated/latin_extended_e.rs
UTF-8
13,170
2.8125
3
[ "LicenseRef-scancode-unicode" ]
permissive
/// An enum to represent all characters in the LatinExtendedE block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum LatinExtendedE { /// \u{ab30}: 'ꬰ' LatinSmallLetterBarredAlpha, /// \u{ab31}: 'ꬱ' LatinSmallLetterAReversedDashSchwa, /// \u{ab32}: 'ꬲ' LatinSmallLetterBlackletterE, ...
true
0af5b17bbea5b51508d352815f08bcf1bcaa1695
Rust
nats-io/nats.rs
/nats/src/lib.rs
UTF-8
29,011
2.75
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2022 The NATS Authors // 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 applicable law or agreed to ...
true
5330945c83bb264cd5506742b9f7767b372eaece
Rust
lumen/examples
/spawn-chain/wasm/src/elixir/chain/counter_2/label_4.rs
UTF-8
915
2.609375
3
[]
no_license
//! ```elixir //! # label 4 //! # pushed stack: (output, next_pid) //! # returned from call: sent //! # full stack: (sent, output, next_pid) //! # returns: :ok //! sent = ... //! output.("sent #{sent} to #{next_pid}") //! ``` use std::convert::TryInto; use liblumen_alloc::erts::exception; use liblumen_alloc::erts::pr...
true
ed49c60d0ffe3bf0e056aef2d4904f39a5ec9c87
Rust
dstu/thud
/thud_ui_common/src/lib.rs
UTF-8
3,439
2.59375
3
[ "Apache-2.0" ]
permissive
use clap::{self, arg_enum}; use thud_game::{self, board}; // pub use thud_game::ai::mcts::deconvolve_transpositions::Game as ThudGame; // pub use thud_game::ai::mcts::deconvolve_transpositions::Payoff as ThudPayoff; // pub use thud_game::ai::mcts::deconvolve_transpositions::State as ThudState; // pub use thud_game::ai...
true