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
aac4ae104433e0d45417699d76ea2a4756c139ec
Rust
masonium/art-util
/src/math/root_finder.rs
UTF-8
1,331
3.1875
3
[]
no_license
use crate::common::*; /// a + (x - a)* (f(b) - f(a)) / (b -a ) == 0 /// -a * (b-a) / (f(b) - f(a)) == (x -a) /// a * (1 - (b-a) / (f(b) - f(a))) == x /// Find a root within the specified range. /// /// If a root exists, the value `a` returned will have one of the /// following properties: /// /// a) |f(a)| < epsilon ...
true
685557e14d5f99aa02e9a1c593cc11055ef8c13e
Rust
minioin/activities
/src/object/video.rs
UTF-8
566
2.796875
3
[ "Apache-2.0" ]
permissive
use crate::link::Link; use crate::object::{DocumentType, ObjectType, TypedObjectType}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct Video { url: Link, name: String, } impl Video { pub fn new(url: Link, name: String) -> Self { Self { url, name } } } #[typet...
true
83567b82839cd9d83aa2d9ea40cea8f24364b7f2
Rust
yngtodd/kv
/src/main.rs
UTF-8
1,573
3.640625
4
[]
no_license
use std::collections::HashMap; fn main() { let mut args = std::env::args().skip(1); let key = args.next().expect("Key was not there"); let val = args.next().unwrap(); let mut database = Database::new().expect("Creating db failed!"); database.insert(key, val); println!("Database currently has...
true
625957c03755c2f4e54264e2e0eef22c95cd11fe
Rust
MrrRaph/Exercism-Rust
/src/easy/sum-of-multiples/src/lib.rs
UTF-8
212
2.921875
3
[]
no_license
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 { (1..limit).filter(|x| factors.iter().any(|modulo| { if *modulo != 0 { return x % modulo == 0; } false })).sum() }
true
48ffaa5f0d463176cf49a4ef3a13b1fd0c95eec5
Rust
davehorner/playwright-rust
/tests/browser/mod.rs
UTF-8
1,699
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
use super::Which; use playwright::api::{Browser, BrowserType}; pub async fn all(t: &BrowserType, which: Which) -> Browser { launch_close_browser(t).await; let b = launch(t).await; assert!(b.exists()); version_should_work(&b, which); contexts_should_work(&b).await; b } async fn launch(t: &Brows...
true
38207116913a85ede3d91d9e407ffbf3b31f11e3
Rust
shanmiteko/bili_login
/src-tauri/src/http/mod.rs
UTF-8
2,124
2.96875
3
[]
no_license
mod send; use send::HttpRequest; /// GET pub async fn get<K, V>(url: &str, query: Option<Vec<(K, V)>>) -> HttpRequest where K: Into<String>, V: Into<String>, { HttpRequest::make("GET", url, query, None).await } /// POST pub async fn post<K, V>( url: &str, query: Option<Vec<(K, V)>>, body: Opt...
true
ef774ce5c1b73bde27d64c1e9049c1187bab8ebc
Rust
Logicalshift/safas
/src/exec/frame_monad.rs
UTF-8
2,425
3.140625
3
[ "Apache-2.0" ]
permissive
use super::frame::*; use std::marker::{PhantomData}; /// /// Trait implemented by things that represent a 'frame monad' /// pub trait FrameMonad : Send+Sync { type Binding; /// Executes this monad against a frame fn execute(&self, frame: Frame) -> (Frame, Self::Binding); /// Retrieves a description ...
true
fbf75f7fcab6c695c410db06052624a075a1fce6
Rust
SeiryuZ/Projects
/net/port-checker/src/main.rs
UTF-8
1,726
3.328125
3
[ "MIT" ]
permissive
use std::net::TcpStream; use std::sync::{Arc, Mutex}; use std::thread; fn main() { // set up hosts and port to be scanned let mut hosts: Vec<String> = Vec::new(); let ports: Vec<u16> = (1..65535).collect(); for host in 1..255 { let address = format!("192.168.1.{}", host); hosts.push(a...
true
64dfc791e7eb9e6fdac4bda01d4ae38d2a2ec8ee
Rust
Vzaa/advent_of_code_2019
/day01/src/main.rs
UTF-8
695
3.25
3
[ "Unlicense" ]
permissive
use std::fs::File; use std::io::{BufRead, BufReader}; fn p1() { let rdr = BufReader::new(File::open("input").unwrap()); let mass_iter = rdr.lines().map(|l| l.unwrap().parse::<i32>().unwrap()); let fuel_sum: i32 = mass_iter.map(|m| m / 3 - 2).sum(); println!("{:}", fuel_sum); } fn p2_fuel(m: i32) -> i...
true
77f63c793048ac0218d3292c10744941e88909fb
Rust
reactive-systems/RTLola-Frontend
/crates/rtlola-hir/src/modes/types.rs
UTF-8
1,316
2.578125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::{Typed, TypedTrait}; use crate::hir::{ExprId, SRef}; use crate::type_check::{ConcretePacingType, ConcreteValueType, StreamType}; impl TypedTrait for Typed { fn stream_type(&self, sr: SRef) -> HirType { self.get_type_for_stream(sr) } fn is_periodic(&self, sr: SRef) -> bool { matc...
true
8297f72b4daa980e496ec3de543ff44e02976f32
Rust
dylanmckay/protocol
/examples/udp.rs
UTF-8
1,333
3.078125
3
[ "MIT" ]
permissive
#[derive(protocol::Protocol, Clone, Debug, PartialEq)] pub struct Handshake; #[derive(protocol::Protocol, Clone, Debug, PartialEq)] pub struct Hello { id: i64, data: Vec<u8> } #[derive(protocol::Protocol, Clone, Debug, PartialEq)] pub enum Packet { Handshake(Handshake), Hello(Hello), } fn main() { ...
true
ede985a7558c18a5fb8b9832327ba4a2ada13a3f
Rust
Roba1993/rune
/crates/rune/src/ast/lit_bool.rs
UTF-8
1,116
3.4375
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::ast; use crate::{Parse, ParseError, Parser, Peek, Peeker, Spanned, ToTokens}; /// The unit literal `()`. #[derive(Debug, Clone, PartialEq, Eq, ToTokens, Spanned)] pub struct LitBool { /// The token of the literal. pub token: ast::Token, /// The value of the literal. #[rune(skip)] pub val...
true
efb32b26a4aca8b29a113aff764c960c68cb5692
Rust
actix/actix-web
/actix-web/examples/on-connect.rs
UTF-8
1,817
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
//! This example shows how to use `actix_web::HttpServer::on_connect` to access a lower-level socket //! properties and pass them to a handler through request-local data. //! //! For an example of extracting a client TLS certificate, see: //! <https://github.com/actix/examples/tree/master/https-tls/rustls-client-cert> ...
true
87a28e04bcdfb9cf538e19ad6a26332fc88aab0c
Rust
gretchenfrage/manhattan-tree
/src/collections/set.rs
UTF-8
1,458
3.40625
3
[]
no_license
use super::MTreeMap; use space::CoordSpace; /// A degenerate case of the MTreeMap. A set of coordinates in a particular coordinate space /// that allows for queries on the closest element to a particular focus. pub struct MTreeSet<S: CoordSpace> { map: MTreeMap<S::Coord, S> } impl<S: CoordSpace> MTreeSet<S> { ...
true
6ae41e9ba902566219b71f2d09c9d28dbf97323e
Rust
nomalab/rs_file_api
/tests/http_reader.rs
UTF-8
7,707
2.671875
3
[ "MIT" ]
permissive
extern crate file_api; extern crate futures; extern crate hyper; use std::io::{Read, Seek, SeekFrom, Write}; use std::net::TcpListener; use std::thread; use std::time::Duration; use futures::sync::mpsc; use futures::Sink; use file_api::http_reader::HttpReader; use file_api::reader::Reader; fn mock_server(port: &str...
true
ec60f3ada218bfef169d7c8d55b5023fc10eb816
Rust
0x-r4bbit/dapptools-rs
/dapptools/src/utils.rs
UTF-8
2,589
2.921875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{ fs::{File, OpenOptions}, path::PathBuf, }; /// Default deps path const DEFAULT_OUT_FILE: &str = "dapp.sol.json"; /// Initializes a tracing Subscriber for logging pub fn subscriber() { tracing_subscriber::FmtSubscriber::builder() // .with_timer(tracing_subscriber::fmt::time::uptime()) ...
true
614703f3605db1a2197461603bd5578333f7a62e
Rust
lutostag/exercism
/rust/paasio/src/lib.rs
UTF-8
1,328
3.046875
3
[ "MIT" ]
permissive
use std::io::{Read, Result, Write}; pub struct TransferStats<T> { wrapped: T, bytes: usize, calls: usize, } pub use TransferStats as ReadStats; pub use TransferStats as WriteStats; impl<T> TransferStats<T> { pub fn new(wrapped: T) -> ReadStats<T> { ReadStats { wrapped, ...
true
14be415d8d501a82cc460a99fffef189520a5597
Rust
t0phr/shreddr
/src/index/document_repository/mod.rs
UTF-8
2,806
3.015625
3
[ "MIT" ]
permissive
use crate::metadata::tag::TagId; use chrono::serde::{ts_seconds, ts_seconds_option}; pub mod local_repository; #[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct ExtractedData { #[serde(default)] pub phone: Vec<String>, #[serde(default)] pub email: Vec<String>, #[serde(default)] ...
true
745f057308146ba42d44d50bc4acb15158b39855
Rust
CroPo/roguelike-tutorial-2018
/part_5/src/render.rs
UTF-8
786
2.703125
3
[ "WTFPL" ]
permissive
use tcod::console::{Console, Root, blit, Offscreen}; use map_objects::map::GameMap; use tcod::Map; use entity::Entity; pub trait Render { fn draw(&self, console: &mut Console); fn clear(&self, console: &mut Console); } pub fn render_all(objs: &Vec<Entity>, map: &mut GameMap, fov_map: &Map, fov_recompute: boo...
true
8b1d3f2291212530dc247a844d3e9346587b044a
Rust
Nufflee/AdventOfCode-2020
/day08/src/vm.rs
UTF-8
1,937
3.484375
3
[]
no_license
use std::{fmt::Display, str::FromStr}; // TODO: Try to make a stringification macro #[derive(Debug, Copy, Clone)] pub enum Instruction { ACC { value: i32 }, JMP { offset: i32 }, NOP { value: i32 }, } impl Display for Instruction { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match ...
true
c8a6b1908316d5d28dbad04ad52ef3b5c9f89ed5
Rust
Dhs92/wikia_api
/src/search/search.rs
UTF-8
3,470
3.171875
3
[ "MIT" ]
permissive
extern crate reqwest; extern crate serde_json; extern crate url; use super::results::Results; use std::option::Option; use url::Url; #[derive(Debug)] #[allow(missing_docs)] pub struct Search { query: Option<String>, sub_wikia: Option<String>, namespace: Option<String>, limits: Option<String>, } impl ...
true
fe68a14b2ae087af833ce51b8a092a332a5cdfc4
Rust
MathieuAuclair/LearningRustLang
/guessing_game_tutorial/src/main.rs
UTF-8
670
3.6875
4
[]
no_license
extern crate rand; use std::io; use rand::Rng; use std::cmp::Ordering; fn main() { let mut win = false; println!("Guess a number"); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("failed to read line"); let answer = rand::thread_rng().gen_range(1,11); let gues...
true
27de17be7254d7fab518fdb18f5c860209383d8e
Rust
alaricsp/rust-workshop
/04-error-handling/src/main.rs
UTF-8
2,841
4.125
4
[ "MIT", "Apache-2.0", "CC-BY-4.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
// This function returns an `Option`. An `Option` is a type, that is either a value or nothing. Or // to be more precise, that is either `Some(T)` or `None`. // // You can see the `None` part of `Option` as the `null` pointer in Rust. But different from `null` // pointers in other languages, Rust forces you to deal wit...
true
7fa94d4d3ea477804259614d9ee1a04984d6f45d
Rust
media-cloud-ai/rs_file_system_worker
/src/action/list.rs
UTF-8
999
2.859375
3
[ "MIT" ]
permissive
use std::io::Error; use std::path::Path; use mcai_worker_sdk::{info, warn}; use crate::action::Action; pub struct ListAction { source_paths: Vec<String>, } impl ListAction { pub fn new(source_paths: Vec<String>) -> Self { ListAction { source_paths } } } impl Action for ListAction { fn execute(&self) ->...
true
fe536d1a2f1e7cdb8a47e01ff0dd973c74d6ce87
Rust
zhuoyw/timely-dataflow
/communication/src/drain.rs
UTF-8
2,803
3.515625
4
[ "MIT" ]
permissive
//! Placeholder `Drain` implementation for `Vec<T>` until it lands in stable Rust. use std::slice; use std::ptr; pub trait DrainExt<T> { fn drain_temp(&mut self) -> Drain<T>; } impl<T> DrainExt<T> for Vec<T> { fn drain_temp(&mut self) -> Drain<T> { // Memory safety // // When the Drai...
true
93e8554fb0df80e769759296a9ba8e9a76de264b
Rust
bsherman/fred.rs
/examples/sync_borrowed.rs
UTF-8
3,047
3.03125
3
[ "MIT" ]
permissive
#![allow(unused_variables)] #![allow(unused_imports)] //! Same idea as `sync_owned.rs`, but shows how the removal of ownership requirements on commands can make using this much easier. extern crate fred; extern crate tokio_core; extern crate tokio_timer_patched as tokio_timer; extern crate futures; extern crate prett...
true
325f6a964fd148a3a5a05624174c3372d2cf04f6
Rust
kjempelodott/adventofcode
/aoc2018/src/bin/day8.rs
UTF-8
911
2.671875
3
[]
no_license
#[macro_use] extern crate adventofcode2018; use adventofcode2018::read_from_stdin; // Recursive parsing fn parse(h: &mut Iterator<Item=usize>) -> (usize, usize) { let (c, m) = (h.next().unwrap(), h.next().unwrap()); let children = (0..c).map(|_| parse(h)).collect::<Vec<(usize,usize)>>(); let metadata: Vec<...
true
713e9b49b55bc2fe68c5b35948928041253981b0
Rust
gre/gre
/plots/examples/1048/main.rs
UTF-8
9,101
2.640625
3
[ "LicenseRef-scancode-proprietary-license", "CC-BY-4.0", "MIT" ]
permissive
use clap::*; use gre::*; use rand::prelude::*; use std::f64::consts::PI; use svg::node::element::path::Data; use svg::node::element::*; #[derive(Parser)] #[clap()] pub struct Opts { #[clap(short, long, default_value = "image.svg")] file: String, #[clap(short, long, default_value = "210.0")] pub width: f64, #...
true
b9d5353dc57850ebb98cb18b2e1277a99eed92fb
Rust
purple-phoenix/computer_models
/src/logic_gates/logical_gates.rs
UTF-8
2,675
3.296875
3
[]
no_license
use crate::primitives::booleans::{MBoolean}; pub fn make_not() -> fn(&MBoolean) -> MBoolean { |input| match input { MBoolean::TRUE => MBoolean::FALSE, MBoolean::FALSE => MBoolean::TRUE } } pub fn make_and() -> fn(&MBoolean, &MBoolean) -> MBoolean { |input_a, input_b|{ match ...
true
be4789ac7fe4d1126925f1b87c624ab7107e5d3e
Rust
teloxide/teloxide
/crates/teloxide-core/src/payloads/answer_inline_query.rs
UTF-8
2,656
2.9375
3
[ "MIT" ]
permissive
//! Generated by `codegen_payloads`, do not edit by hand. use serde::Serialize; use crate::types::{InlineQueryResult, True}; impl_payload! { /// Use this method to send answers to an inline query. On success, _True_ is returned. No more than **50** results per query are allowed. #[derive(Debug, PartialEq, Cl...
true
844f0836f42ea6030700575425d0640123e6099a
Rust
lineCode/GameServer_Rust
/battleserver/src/robot/robot_status/buy_action.rs
UTF-8
3,636
2.671875
3
[]
no_license
use crossbeam::channel::Sender; use log::{error, info, warn}; use tools::cmd_code::BattleCode; use crate::{ battle::battle::BattleData, robot::{ goal_evaluator::buy_goal_evaluator::check_buy, robot_action::RobotStatusAction, robot_task_mgr::RobotTask, RobotActionType, }, }; use super::Robo...
true
288b6e68742db66be8a847387f29dc33f2f31c84
Rust
ChuWenFeng/myrollup
/models/src/plasma/circuit/account.rs
UTF-8
1,662
2.578125
3
[]
no_license
use crate::plasma::params; use crate::primitives::{GetBits, GetBitsFixed}; use ff::{Field, PrimeField}; use sapling_crypto::alt_babyjubjub::JubjubEngine; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CircuitAccount<E: JubjubEngine> { pub balance: E::Fr, pub nonce: E::Fr, pub pub_x: E::Fr, ...
true
38849997771de9a166b7e55939da3a19cbf1dc15
Rust
hrntsm/study-language
/Rust/ms-rust/chapter7/rusty_pizza/src/lib.rs
UTF-8
409
3.359375
3
[ "MIT" ]
permissive
pub struct Pizza { pub topping: String, pub inches: u8, } impl Pizza { pub fn pepperoni(inches: u8) -> Self { Pizza::bake("pepperoni", inches) } pub fn mozzarella(inches: u8) -> Self { Pizza::bake("mozzarella", inches) } fn bake(topping: &str, inches: u8) -> Self { ...
true
11540d36b11ce20a6f3efb190bb13006bff4a914
Rust
stm32-rs/stm32-rs-nightlies
/stm32f4/src/stm32f469/dsi/lpcr.rs
UTF-8
2,846
2.53125
3
[]
no_license
#[doc = "Register `LPCR` reader"] pub type R = crate::R<LPCR_SPEC>; #[doc = "Register `LPCR` writer"] pub type W = crate::W<LPCR_SPEC>; #[doc = "Field `DEP` reader - Data Enable Polarity"] pub type DEP_R = crate::BitReader; #[doc = "Field `DEP` writer - Data Enable Polarity"] pub type DEP_W<'a, REG, const O: u8> = crat...
true
382ee42e97422455651432e501a02cbc2325e3e9
Rust
Jkillelea/projects
/rust/book/casting.rs
UTF-8
1,379
3.796875
4
[]
no_license
/* * 2 ways to cast in rust. 'as', for safe casts, and 'transmute' for arbitrary ones */ // safe cast: let x: i32 = 5; let y = x as i64; /* * A cast e as U is also valid in any of the following cases: * e has type T and T and U are any numeric types; numeric-cast * e is a C-like enum (with no data attached...
true
7ffd055131180ad4e9f19a4bbe72d6ad84e97f8b
Rust
vi/proptest-http
/src/uri.rs
UTF-8
5,564
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
use super::*; /// Wrapper that generates random-ish `Uri` instances. /// Not that URI generation is rather basic. There probably /// a lot of tricky cases that are not considered #[derive(Debug, PartialEq, Eq, Clone)] pub struct ArbitraryUri(pub http::Uri); #[derive(Debug, Clone, Copy)] pub struct UriStrategy; #[deriv...
true
77d96ae22bed35e44a85fb9a972b38b9878f2e1f
Rust
azriel91/autexousious
/crate/game_play_hud/src/system/cp_bar_update_system.rs
UTF-8
3,274
2.65625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use amethyst::{ core::Transform, ecs::{Join, ReadStorage, System, World, WriteStorage}, renderer::SpriteRender, shred::{ResourceId, SystemData}, }; use charge_model::play::ChargeTrackerClock; use derivative::Derivative; use derive_new::new; use parent_model::play::ParentEntity; use crate::{CpBar, CP_BA...
true
0cdff4f75241d528abd0264943287fed5cebdcce
Rust
laohanlinux/simple-bitcoin-rs
/src/merkle_tree.rs
UTF-8
2,348
3.21875
3
[]
no_license
use super::util; use std::iter; #[derive(Debug, Clone)] pub struct MerkleTree { pub root: Option<Box<MerkleNode>>, } #[derive(Debug, Clone)] pub struct MerkleNode { pub data: Box<Vec<u8>>, left: Option<Box<MerkleNode>>, right: Option<Box<MerkleNode>>, } impl MerkleTree { // just build the root ...
true
a460f8b07d8eb031a75a5ff5408120ff03cf0bb3
Rust
chaosannals/trial-rust
/logsrv/tcpclient/src/main.rs
UTF-8
2,052
2.78125
3
[]
no_license
use std::{ io, str, io::{ Write, Read, Result, }, result, }; use std::net::{TcpStream}; use std::error::Error; use aes_gcm_siv::{ aead::{AeadInPlace, KeyInit, OsRng, Aead}, Aes256GcmSiv, Nonce }; use generic_array::{ GenericArray, ArrayLength, }; fn main() ->...
true
c880b6c332584894349957a4a2a391e3156dc920
Rust
likr/atcoder
/arc023/src/bin/b.rs
UTF-8
658
2.578125
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn...
true
c05b3ad278163024d7455ccb91dfe118330dfe1a
Rust
herojan/adventofcode2020
/day15/src/main.rs
UTF-8
1,148
3.375
3
[]
no_license
use std::collections::HashMap; use std::fs::read_to_string; fn main() { let input = read_to_string("input.txt").unwrap(); println!("Part 1: {:?}", find_last_num(&input, 2020)); println!("Part 2: {:?}", find_last_num(&input, 30000000)); } fn find_last_num(input: &str, target_turn_num: u32) -> u32 { let...
true
0f1bf9366d96384b5c9f1980a4e0c8372f5dc53c
Rust
RyanMeulenkamp/solplan-rust
/src/model/panel.rs
UTF-8
2,415
3.234375
3
[ "Apache-2.0" ]
permissive
use druid::{Data, Lens}; use crate::model::orientation::Orientation; use serde::{Serialize, Deserialize}; #[derive(Clone, PartialEq, PartialOrd, Data, Lens, Serialize, Deserialize)] pub struct Panel { name: String, width: f64, height: f64, peak_power: f64, price: f64, selected: bool, } impl Pa...
true
c310ea04958762196266974db184cbae9129bf72
Rust
Tyg13/tylang
/crates/parser/src/types.rs
UTF-8
7,621
2.921875
3
[]
no_license
use cst::green::Subtokens; use super::*; pub struct Parser<'tokens> { tokens: &'tokens dyn TokenSource, token_index: usize, events: Vec<Event>, follow_stack: Vec<HashSet<SyntaxKind>>, steps: u64, } #[derive(Debug, Clone, PartialEq, Eq)] pub enum Event { NodeStart(SyntaxKind, Option<usize>), ...
true
d5f24da7658a45132e5b32552f90a971331ff647
Rust
quentpilot/my-rust-tests
/sql-generator/src/generators.rs
UTF-8
2,156
3.1875
3
[ "MIT" ]
permissive
pub struct Config { pub nb_queries: usize, pub nb_rows: usize, pub table_name: String, pub file_name: String, pub data_pattern: String, pub random: usize, pub verbose: usize, } pub struct Data { pub key: String, pub value: String, } pub struct Generator { config: Config, da...
true
9d9231fb360e567c2278b158624895a2fec91745
Rust
jacklund/tokio-socks
/src/error.rs
UTF-8
2,323
2.859375
3
[ "MIT" ]
permissive
/// Error type of `tokio-socks` #[derive(thiserror::Error, Debug)] pub enum Error { /// Failure caused by an IO error. #[error("{0}")] Io(#[from] std::io::Error), /// Failure when parsing a `String`. #[error("{0}")] ParseError(#[from] std::string::ParseError), /// Failure due to invalid targ...
true
34a5f4fe9b549537a95d3be015e2361fcbd5c36c
Rust
valekar/tradingbot
/src/utils/util.rs
UTF-8
1,348
3.15625
3
[]
no_license
use dotenv::dotenv; pub fn display_contents(elements: &Vec<f64>) { println!("Contents of array ::"); for element in elements { print!(" {}", element) } println!(" ") } pub fn load_env() { println!("Loading .env variables!!"); dotenv().ok(); } pub fn buy( investment: &'static mut V...
true
5c7029af0a65dff5868a2c46a957ac3effeb4c11
Rust
dylanmckay/hmdee
/hmdee/src/info/lens.rs
UTF-8
1,155
2.9375
3
[ "MIT" ]
permissive
use crate::{core::math, info}; /// An individual lens. #[derive(Clone, Debug, PartialEq, PartialOrd)] pub struct Lens { /// The screen resolution of the lens. pub resolution: (u32, u32), /// The FOV of the lens. pub field_of_view: info::FieldOfView, /// The coefficients for the barrel distortion eq...
true
8aa342ce32f98e245bf3701c1e0fea8a1029a813
Rust
dragonlayout/rust-book-note
/lifetimes/src/main.rs
UTF-8
2,413
3.984375
4
[]
no_license
fn main() { // every reference int Rust has a lifetime, which is the scope for which that reference is valid. // like types are referred, wo must annotate lifetimes when the lifetimes of references could be // related in a few different ways { let x = 5; // ----------+-- 'b ...
true
0e1ccd355e79a4141279114837d799f4e5fd44ec
Rust
kjh618/riscv-simulator
/src/ast.rs
UTF-8
10,291
2.9375
3
[]
no_license
use phf::phf_map; use crate::parser; #[derive(Debug, Copy, Clone)] pub struct Register { pub index: u8, } #[derive(Debug, Copy, Clone)] pub enum JumpTarget<'a> { Label(&'a str), Offset(i32), } #[derive(Debug, Copy, Clone)] pub struct Address { pub offset: i32, pub base: Register, } #[derive(Debu...
true
d16057fde117cc9d4b4a301c3601f050623d81fa
Rust
kitchen/aoc2020
/day7/src/bin/part2.rs
UTF-8
3,060
3.359375
3
[ "LicenseRef-scancode-public-domain", "Unlicense" ]
permissive
extern crate regex; use regex::Regex; use std::collections::{HashMap, HashSet}; use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::iter::FromIterator; fn main() { let args: Vec<String> = env::args().collect(); let filename = &args[1]; // this will panic if there's no argument which is fine...
true
1e2c55a288202a12826d016ad897f70bd1e2e9d6
Rust
mhspradlin/curl-but-worse
/src/dispatcher.rs
UTF-8
3,184
2.71875
3
[ "MIT" ]
permissive
use color_eyre::eyre::{Result, WrapErr}; use futures::future; use tokio::sync::mpsc; use tokio::sync::mpsc::{Receiver, Sender}; use tokio::task::JoinHandle; use crate::messages::{Command, CommandResult}; use reqwest::Client; use std::time::Duration; pub async fn dispatcher( mut command_source: Receiver<Command>,...
true
a73ba4476170fa2f5c0e1a617c714487eaa417a8
Rust
invenia/rusoto
/src/request.rs
UTF-8
2,134
3.15625
3
[ "MIT" ]
permissive
//! AWS API requests. //! //! Wraps the Hyper library to send PUT, POST, DELETE and GET requests. use std::io::Read; use hyper::Client; use hyper::client::Response; use hyper::client::RedirectPolicy; use hyper::header::Headers; use hyper::method::Method; use signature::SignedRequest; use log::LogLevel::Debug; /// Ta...
true
5f3e9d9f2c5ead27c60d177175b4f01e4e907406
Rust
JulianKnodt/mireba
/src/integrator/mod.rs
UTF-8
2,577
2.890625
3
[]
no_license
pub mod builder; pub mod depth; pub mod direct; use crate::{ accelerator::Accelerator, camera::{Camera, Cameras}, scene::Scene, spectrum::Spectrum, utils::morton_decode, }; use quick_maths::{Ray3, Vec2, Vector, Zero}; use std::fmt::Debug; pub trait Integrator: Debug { fn render<El, Acc: Accelerator>(&self...
true
2332fd031d7bc0e66043b33798776502951a115c
Rust
aheart/toy-assembler
/src/writer.rs
UTF-8
795
2.984375
3
[]
no_license
use crate::elf::{align, Elf}; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::io::SeekFrom; use std::mem::size_of; pub fn write_binary(elf: &Elf, machine_code: &[u8], data: &str) -> Result<(), Box<dyn Error>> { let mut file = File::create("executable")?; let elf_bytes: &[u8] = unsa...
true
2076d87a297f8592cba9e548f2193fc976c33ed3
Rust
vaibhavantil2/third-party-api-clients
/docusign/src/template_document_fields.rs
UTF-8
6,859
2.703125
3
[ "MIT" ]
permissive
use anyhow::Result; use crate::Client; pub struct TemplateDocumentFields { pub client: Client, } impl TemplateDocumentFields { #[doc(hidden)] pub fn new(client: Client) -> Self { TemplateDocumentFields { client } } /** * Gets the custom document fields for a an existing template doc...
true
126c05fb86b5f8293171ad472c321000e2b3354d
Rust
cgrewon/solana-escrow-contract
/src/state.rs
UTF-8
4,114
3.3125
3
[]
no_license
/// state.rs -> program objects, (de)serializing state use solana_program::{ program_pack::{IsInitialized, Pack, Sealed}, program_error::ProgramError, pubkey::Pubkey, }; // arrayref library is used to get references to sections of a slice // https://docs.rs/arrayref/latest/arrayref/ use arrayref::{array_mut_ref, a...
true
b520e2759308d1de9ca34e64cf37c3f5e66cd630
Rust
GaloisInc/crucible
/crux-mir/test/symb_eval/array/basic.rs
UTF-8
347
2.734375
3
[ "BSD-3-Clause" ]
permissive
extern crate crucible; use crucible::array::Array; #[crux::test] fn crux_test() -> i32 { let arr = Array::<i32>::zeroed(); let arr = arr.update(0, 0); let arr = arr.update(1, 1); let arr = arr.update(2, 2); arr.lookup(0) + arr.lookup(1) + arr.lookup(2) + arr.lookup(99) } pub fn main() { printl...
true
7c1d7ab8a6ef8ebd7176ce118539793565b898f6
Rust
johansmitsnl/oxfeed
/front/src/components/switch.rs
UTF-8
1,475
3.15625
3
[]
no_license
pub(crate) enum Message { Toggle, } #[derive(Clone, yew::Properties)] pub(crate) struct Properties { pub id: String, #[prop_or_default] pub label: String, #[prop_or_default] pub active: bool, #[prop_or_default] pub on_toggle: yew::Callback<bool>, } pub(crate) struct Component { lin...
true
778dead9be426cdcfc90ff0435b705f2280bf694
Rust
bernabeguzman/Final_Elma_Rust
/ELMA_Rust1/src/test/process_test.rs
UTF-8
221
2.859375
3
[ "MIT" ]
permissive
pub trait Quack { fn quack(&self); } pub struct Process { pub is_parrot: bool } impl Quack for Process { fn quack(&self) { if ! self.is_parrot { println!("quack"); } else { println!("sqwak"); } } }
true
88a3b4653f3b4d3308a65f8d5600408a3c5aadda
Rust
Andoryuuta/badrng
/badrng/src/lib.rs
UTF-8
2,086
3.265625
3
[]
no_license
use std::process::Command; use std::sync::{ mpsc, mpsc::{Receiver, Sender}, }; use std::thread; fn get_unsound_byte() -> u8 { // Call into the bad-rng-internal-bin binary to get a "random" byte. let status = if cfg!(target_os = "windows") { Command::new("cmd") .arg("/c") ...
true
dcc04f97c27adb664e260ccacf271d35c17a2e0c
Rust
crazymerlyn/jasm-rs
/src/method.rs
UTF-8
535
2.640625
3
[]
no_license
use serializer::Serializable; use attribute::Attribute; use common::AccessFlags; use std::io::Write; use std::io::Result; pub struct Method { access_flags: AccessFlags, name_index: u16, desc_index: u16, attributes: Vec<Attribute>, } impl Method { } impl Serializable for Method { fn serialize<W: ...
true
e7a865a060e16474836c42924faa3fe6173df2e6
Rust
thunderseethe/amethyst
/amethyst_core/src/float.rs
UTF-8
15,917
2.890625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{ fmt::{Display, Formatter}, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign}, }; use crate::num::{Bounded, FromPrimitive, Num, One, ParseFloatError, Signed, Zero}; use alga::general::*; use approx::{AbsDiffEq, RelativeEq, UlpsEq}; use nalgebra::Complex; #[cf...
true
befa7d5f920a8ab97f7deaefaba45731f89eceba
Rust
SrimantaBarua/bed
/src/language_client/uri.rs
UTF-8
9,580
2.828125
3
[ "MIT" ]
permissive
// (C) 2020 Srimanta Barua <srimanta.barua1@gmail.com> // FIXME: This is not a validating URI parser. That could (probably will) cause vulnerabilities. // Maybe fix them. This is also not a complete URI parser. It doesn't parse the ?query and #frament // parts of a URI, since I think they're not needed for the languag...
true
15035b262f4898ca4150433c66515b73af747ebb
Rust
visigoth/hkutils
/hkctl/src/room.rs
UTF-8
1,748
2.515625
3
[]
no_license
use clap::{ArgMatches}; use simple_error::{SimpleError, SimpleResult}; use std::boxed::Box; use std::future::Future; use std::pin::Pin; use std::str::FromStr; use tonic::transport::Channel; use crate::hkservice::home_kit_service_client::HomeKitServiceClient; use crate::hkservice::{AddRemoveRoomRequest, AddRemoveRoomRes...
true
9c0904530edba8b84a4352b04452086892122e6c
Rust
async-rs/async-std
/src/stream/fused_stream.rs
UTF-8
961
3.34375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::stream::Stream; /// A stream that always continues to yield `None` when exhausted. /// /// Calling next on a fused stream that has returned `None` once is guaranteed /// to return [`None`] again. This trait should be implemented by all streams /// that behave this way because it allows optimizing [`Stream::...
true
677234242732e0ff78b48abb4a0dd0c992c812c4
Rust
pum-purum-pum-pum/bioinfo
/tasks/examples/greedy_motif.rs
UTF-8
4,358
2.875
3
[]
no_license
use std::{ fs::File, io::{BufWriter, Write}, collections::{HashMap, HashSet}, io::prelude::*, }; // #[macro_use] // extern crate lazy_static; // #[macro_use] // extern crate itertools; // use itertools::Itertools; pub fn profile_from_motifs(motifs: &Vec<String>, k: usize) -> Vec<Vec<f32>> { let m...
true
a3674e88c4d5c4a7212973b463f08e2e309759c9
Rust
deadcore/learn-to-write-a-database
/src/statements/create.rs
UTF-8
890
3.15625
3
[]
no_license
use std::borrow::Borrow; #[derive(Debug)] pub enum DataType { Int32, String, } #[derive(Debug)] pub struct ColumnDefinition { name: String, data_type: DataType, } impl ColumnDefinition { pub fn new(name: String, data_type: DataType) -> Self { ColumnDefinition { name, data_type } } ...
true
55715b29362be36ff87fbb2355a71667d009d2cf
Rust
clemson-cal/gridiron
/src/message/comm.rs
UTF-8
3,318
3.515625
4
[]
no_license
//! Exports the `Communicator` message-passing trait. use super::util; /// Interface for a group of processes that can exchange messages over a /// network. /// /// The underlying transport can in principle be TCP, UDP, or another /// abstraction layer like MPI. The communicator is stateful, in the sense /// that it ...
true
e007497fa57375ce8dc7166a185dadadc77b5d4f
Rust
J-F-Liu/geom3d
/src/curve/bezier.rs
UTF-8
1,977
3.1875
3
[ "MIT" ]
permissive
use super::Curve; use crate::basis::bernstein; use crate::{utils, Float, Point3, Point4}; #[derive(Debug)] pub struct BezierCurve<P> { pub control_points: Vec<P>, } impl<P> BezierCurve<P> { pub fn degree(&self) -> usize { self.control_points.len() - 1 } } impl<P: std::ops::Sub<Output = P> + std::...
true
31f388ef665e1c3e0e24395eff621fb38e031fb6
Rust
k0nserv/advent-of-rust-2018
/src/day04.rs
UTF-8
8,310
3.109375
3
[ "MIT" ]
permissive
use regex::Regex; use std::collections::HashMap; use std::cmp::Ordering; lazy_static! { static ref PATTERN: Regex = Regex::new(r"\[\s*(\d+)\-(\d+)\-(\d+)\s+(\d+):(\d+)\s*").unwrap(); } #[derive(Debug, Copy, Clone, Eq, PartialEq)] struct DateTime { year: usize, month: usize, day: usize, hour: usiz...
true
b59f1791771aac3edaafad447109eac569c4f51a
Rust
boa-dev/boa
/boa_engine/src/object/operations.rs
UTF-8
44,383
2.90625
3
[ "MIT", "Unlicense" ]
permissive
use crate::{ builtins::{function::ClassFieldDefinition, Array}, context::intrinsics::{StandardConstructor, StandardConstructors}, error::JsNativeError, object::{JsFunction, JsObject, PrivateElement, PrivateName, CONSTRUCTOR, PROTOTYPE}, property::{PropertyDescriptor, PropertyDescriptorBuilder, Prope...
true
affaabfd8ed5c63c9d1aaec4310591fe5e167b10
Rust
Itanq/RayTracingWithRust
/src/main.rs
UTF-8
1,598
3.0625
3
[]
no_license
extern crate image; extern crate RayTracingWithRust; use RayTracingWithRust::ray_tracing::{Vec3, Ray}; fn main() { let lower_left_corner = Vec3{ point: (-2.0, -1.0, -1.0) }; let horizontal = Vec3{ point: (4.0, 0.0, 0.0) }; let vertical = Vec3{ point: (0.0, 2.0, 0.0) }; let original = Vec3{ point: (0....
true
d4feb3503228dd81185845fd40ae23f1f1fdbe40
Rust
enricobn/slideshow
/src/transitions/transition.rs
UTF-8
1,289
2.890625
3
[]
no_license
use ggez::*; use ggez::graphics::{Color, Drawable, DrawParam, Image}; use image::RgbaImage; use crate::ggez_utils::Point2; pub trait Transition { /// Should return true if the transition is still running. fn draw(&mut self, ctx: &mut Context) -> GameResult<bool>; fn update_image(&mut self, ctx: &mut Cont...
true
2f1a0ff0c05d46384d083bf347696ad632f7f29c
Rust
TrolledWoods/raycaster
/src/render.rs
UTF-8
3,270
2.953125
3
[]
no_license
use crate::float_range; use crate::texture::VerticalImage; use std::marker::PhantomData; pub struct ImageColumn<'a> { // The buffer, as well as buffer.add(stride), buffer.add(stride * 2) e.t.c. until // buffer.add(stride * (height - 1)) should only be accessed by this struct for 'a, // and should be valid ...
true
7b8277c203df8c23e37776d5356cdc4f07e9de4c
Rust
azhi/crowd-sim
/core/src/simulation/time.rs
UTF-8
567
3
3
[]
no_license
extern crate anymap; use self::anymap::AnyMap; pub struct Time { pub current_time: f64, pub end_time: f64, pub tick: f64 } impl Time { pub fn new(configuration: &AnyMap) -> Time { let end_time = config!(configuration, TimeEndTime); let tick = config!(configuration, TimeTick); ...
true
23771b666d3b621b415512e08897d671b7bb6d24
Rust
wearypossum4770/silver-umbrella
/unsorted/main.rs
UTF-8
1,408
2.796875
3
[]
no_license
use crate::addition::addition; use crate::convert_minutes_to_seconds::convert_minutes_to_seconds; use crate::count_matches::count_matches; use crate::defang_ip_addr::defang_ip_addr; use crate::give_me_something::give_me_something; use crate::increment::increment; use crate::is_palindrome::is_palindrome; use crate::next...
true
1488882b9ac0d16aa73df16c3924ea174fb4a8e8
Rust
bits-of-rust/excursion-000
/fibonacci/src/main.rs
UTF-8
586
3.375
3
[ "MIT" ]
permissive
fn main() { println!("fibonacci({}) = {}", 0, fibonacci(0)); println!("fibonacci({}) = {}", 1, fibonacci(1)); println!("fibonacci({}) = {}", 2, fibonacci(2)); println!("fibonacci({}) = {}", 3, fibonacci(3)); println!("fibonacci({}) = {}", 4, fibonacci(4)); println!("fibonacci({}) = {}", 5, fibon...
true
7a1bad36a05eeb3647a6e1fdcd319e09079f41c1
Rust
TheLetterTheta/2020-Advent-of-Code
/solutions_rust/src/day2.rs
UTF-8
1,532
3.09375
3
[]
no_license
use aoc_runner_derive::{aoc, aoc_generator}; use regex::Regex; pub struct PasswordValidator { first: usize, second: usize, character: char, password: String, } #[aoc_generator(day2)] pub fn input_generator(input: &str) -> Vec<PasswordValidator> { lazy_static! { static ref PATTERN: Regex = ...
true
35fc9686c5391b1bceb0ced5a359f77a594fdc59
Rust
daaniiieel/danivim
/src/ui/popupmenu/completion_item_widget.rs
UTF-8
5,739
2.734375
3
[ "MIT" ]
permissive
use gtk::prelude::*; use crate::nvim_bridge::{CompletionItem, CompletionItemKind}; use crate::ui::color::Color; macro_rules! icon { ($file:expr, $color:expr, $size:expr) => { format!(include_str!($file), $size, $size, $color,) }; } /// Wraps completion item into a structure which contains the item an...
true
91da36094bae03f5ef3db5ba91d074328f7741a1
Rust
LonnonDev/GlubGlub
/src/useful.rs
UTF-8
11,449
2.703125
3
[]
no_license
use rand::{Rng, thread_rng}; use serenity::builder::CreateEmbed; use serenity::client::Context; use serenity::model::channel::Message; use tokio_postgres::{Error, NoTls, types::ToSql}; use crate::format_emojis; const POSTGRE: &'static str = "host=192.168.1.146 user=postgres"; pub const GRIST_TYPES: (&'stat...
true
392495e7d77d35837d3d062dcb491e31090a737a
Rust
amitayadav/rustify-user-service
/rust_user_service/user/src/user_service_impl/utilities/mappers.rs
UTF-8
278
2.6875
3
[]
no_license
use crate::user_service_impl::models::p_user::PUser; use crate::user_service_api::models::user::User; /// map_user is used to map PUser into User pub fn map_user(user: PUser) -> User { User { id: user.id, name: user.name, email: user.email, } }
true
8cdd79d49269cbefe6707e15ebbd42066cb9e118
Rust
shika-blyat/regex-engine
/src/regex.rs
UTF-8
214
2.515625
3
[]
no_license
#[derive(Debug)] pub enum Regex { Concat(Box<Regex>, Box<Regex>), Or(Box<Regex>, Box<Regex>), Quantified(Quantifier, Box<Regex>), Char(char), } #[derive(Debug)] pub enum Quantifier { Kleene, }
true
b33d33f9922af6cea73fa3deb8cdf72d07ede539
Rust
lukemetz/rust-raytrace
/src/transform.rs
UTF-8
10,117
2.765625
3
[]
no_license
use geometry::{Vec3, Point, Ray, Normal}; use std::f32::to_str; use std; #[deriving(Eq, Clone)] pub struct Mat4 { pub data : ~[f32] } impl Mat4 { pub fn diag(d : f32) -> Mat4 { let mut data = ~[0.0f32, ..16]; data[0] = d; data[5] = d; data[10] = d; data[15] = d; Mat4 { data: data } } ...
true
82daebbcc20a3a2b082740e90caa0d64291cbaba
Rust
RamAddict/INE5426
/src/ast.rs
UTF-8
19,682
2.5625
3
[]
no_license
#![allow(dead_code)] #![allow(unused_imports)] use std::borrow::Borrow; use std::cell::RefCell; use std::fmt::write; use std::fmt::Display; use std::rc::Rc; // Import Dependencies use crate::ParserCC20211; use crate::Rule; use pest::Parser; use pest::Span; use pest_ast::*; use ptree::print_tree; use ptree::TreeBuilder...
true
a4897cf89b411936fdc25a2548be1525d8cf78ba
Rust
LukeMiles49/init-trait-rs
/src/lib.rs
UTF-8
5,653
4.28125
4
[]
no_license
//! A helper trait to inialise data structures using a function applied to each 'index'. //! //! This is intended to simplify the initialisation of 'indexable' data structures to non-default //! values. For example, if you wanted to initialise a long or arbitrary length array, you would //! need to first initialise it ...
true
3bf5ef38aecf0ecc9c9b2d1c6553761982a7ba44
Rust
gnoliyil/fuchsia
/src/devices/lib/bind/src/debugger/device_specification.rs
UTF-8
6,553
2.953125
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2019 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. use crate::parser::common::{ compound_identifier, condition_value, many_until_eof, map_err, ws, BindParserError, CompoundIdentifier, NomSpan, Value...
true
33be4c0df641f59619805c9fe48add6e1a39d839
Rust
starblue/dust
/dust-cortex-m/src/scb.rs
UTF-8
4,667
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use volatile_register::{RO, RW}; /// System Control Block /// /// This is the v8-M mainline version with all registers. /// Smaller cores implement only a subset of registers, /// and some registers depend on configuration options, /// but this is currently not implemented. // TODO implement different configurations #...
true
e3b169420313f3b519835f5cdacad1fa98087f95
Rust
RReverser/serdebug
/lib/src/tuple.rs
UTF-8
1,408
2.65625
3
[ "MIT" ]
permissive
use debug::debug; use error::Error; use serde::ser::{Serialize, SerializeTuple, SerializeTupleStruct, SerializeTupleVariant}; use std::fmt::{DebugTuple, Formatter}; pub struct Serializer<'a, 'b: 'a>(DebugTuple<'a, 'b>); impl<'a, 'b: 'a> Serializer<'a, 'b> { pub fn new(f: &'a mut Formatter<'b>, name: &str) -> Self...
true
db74941e7ebc3f090a04d4921936af1f48bf1c7d
Rust
jaywalker76/LocustDB
/src/mem_store/strings.rs
UTF-8
7,626
2.59375
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::collections::hash_set::HashSet; use std::hash::BuildHasherDefault; use std::rc::Rc; use std::str; use std::sync::Arc; use std::{u8, u16, u32}; use num::PrimInt; use seahash::SeaHasher; use hex; use stringpack::*; use engine::data_types::*; use mem_store::*; use mem_store::colum...
true
5f34c25a80c39ac9bca8785048c5a93dd28d7e43
Rust
akerber47/knoxide
/src/mix_core.rs
UTF-8
6,754
3.125
3
[]
no_license
use crate::mix_types::*; use crate::mix_util; // Helper function to panic the system. // Stops running and puts the given message into the panic field. fn do_panic(st: &mut MixState, msg: String) -> () { st.is_running = false; st.panic_msg = Some(msg); } // Helper function to pull out address and apply index ...
true
7cf937cf1e889062b58839dece221125b1dd280c
Rust
martinpeck/rust-playpen
/vectorplay/src/main.rs
UTF-8
450
3.140625
3
[ "MIT" ]
permissive
fn main() { let _v: Vec<i32> = Vec::new(); let mut v = vec![1,2,3]; v.push(4); v.push(5); v.push(6); let third: &i32 = &v[2]; println!("The third element is {}", third); match v.get(2) { Some(third) => println!("The third element is {}", third), None =...
true
d2b711b5b5ab5af00a9f44e831fa46d4522e8f55
Rust
amethyst/grumpy_visitors
/bins/client/src/ecs/system_data/ui.rs
UTF-8
1,668
2.734375
3
[ "MIT", "CC-BY-NC-4.0" ]
permissive
use amethyst::{ ecs::{storage::GenericReadStorage, Entities, Entity, Join, World, WriteStorage}, shred::{ResourceId, SystemData}, ui::{UiText, UiTransform}, }; #[derive(SystemData)] pub struct UiFinderMut<'s> { entities: Entities<'s>, storage: WriteStorage<'s, UiTransform>, } impl<'s> UiFinderMut<...
true
5db3956b3bffaef8a4108095337e6adc570e3ee9
Rust
fruit-in/exercism-solution
/rust/phone-number/src/lib.rs
UTF-8
395
3.203125
3
[ "MIT" ]
permissive
pub fn number(user_number: &str) -> Option<String> { let mut digits = user_number .chars() .filter(|ch| ch.is_ascii_digit()) .collect::<Vec<_>>(); if digits.len() == 11 && digits[0] == '1' { digits.remove(0); } if digits.len() != 10 || digits[0] < '2' || digits[3] < '2'...
true
95ff03ec112822ff5f4db22cc31640a406b9044c
Rust
riscv-rust/gd32vf103xx-hal
/src/delay.rs
UTF-8
4,052
2.890625
3
[ "ISC" ]
permissive
//! Delays use crate::timer::Timer; use crate::time::U32Ext; use cast::u32; use embedded_hal::blocking::delay::{DelayMs, DelayUs}; use embedded_hal::timer::CountDown; use gd32vf103_pac::{TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5, TIMER6}; use crate::rcu::Clocks; /// Machine mode cycle counter (`mcycle`) as a de...
true
5be221fb4377e195b13fdc08041bbc659028e43d
Rust
yskszk63/ssssh
/src/msg/channel_extended_data.rs
UTF-8
1,467
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use derive_new::new; use super::*; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub(crate) enum DataTypeCode { Stderr, Unknown(u32), } impl Pack for DataTypeCode { fn pack<P: Put>(&self, buf: &mut P) { match self { Self::Stderr => 1, Self::Unknown(v) => *v, } ...
true
6b3fedd2a52ba07bfddf073c83a33479fbeafad0
Rust
safrannn/leetcode_rust
/src/_1534_count_good_triplets.rs
UTF-8
869
3.6875
4
[]
no_license
struct Solution; impl Solution { pub fn count_good_triplets(arr: Vec<i32>, a: i32, b: i32, c: i32) -> i32 { let n: usize = arr.len(); let mut result: i32 = 0; for i in 0..n { for j in i + 1..n { if (arr[i] - arr[j]).abs() > a { continue; ...
true
b3354175ead7286418721d6492cdb700a7432344
Rust
ganmacs/playground
/rust/llvm-example/src/llvm1.rs
UTF-8
2,996
2.984375
3
[]
no_license
// -------------------- // int main() { // a = 10; // b = 11; // ret = a + b; // return ret; // } // -------------------- extern crate llvm_sys as llvm; use std::ffi::CString; use std::ptr; pub unsafe fn run() { // Get context let context = llvm::core::LLVMGetGlobalContext(); // this instr is th...
true
26cee8d5ab1443b999a8ca6bf2e2ce752d22085a
Rust
maminej/rust_sandbox
/src/arrays.rs
UTF-8
561
4.0625
4
[]
no_license
// Arrays are fixed lists where elements are the same data types use std::mem; pub fn run(){ let numbers:[i32;10] = [1,2,3,4,5,6,7,8,9,10]; //println!("{:?}",numbers ); // Get single value println!("Ela is a cute girl and is {:?} years old", numbers[8] ); // get array length print...
true
136d99337fe0eac4392596e6479dc7409289b630
Rust
tailhook/trimmer
/src/lib.rs
UTF-8
2,285
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Trimmer: A yet another text template engine //! //! [User Guide](https://trimmer.readthedocs.io/) | //! [Github](https://github.com/tailhook/trimmer/) | //! [Crate](https://crates.io/crates/trimmer) //! #![recursion_limit="100"] #![warn(missing_docs)] extern crate combine; extern crate owning_ref; extern crate reg...
true
cf3dda6c605251a519f80922d293502d174ca1d3
Rust
scurest/apicula
/src/convert/gltf/gltf.rs
UTF-8
5,862
2.90625
3
[ "0BSD" ]
permissive
use json::JsonValue; use std::io::Write; pub struct GlTF { pub buffers: Vec<Buffer>, pub json: JsonValue, } pub struct Buffer { pub bytes: Vec<u8>, pub alignment: usize, } impl GlTF { pub fn new() -> GlTF { GlTF { buffers: vec![], json: object!( "as...
true