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
52194923697241cdab3f1538850f822a0e0c1f5d
Rust
JosefKuchar/AoC-2017
/src/day15/solution.rs
UTF-8
1,192
3.265625
3
[ "MIT" ]
permissive
pub fn solve() { let part1 = part1(699, 124); let part2 = part2(699, 124); println!("{} {}", part1, part2); } fn part1(a: usize, b: usize) -> usize { let mut a = a; let mut b = b; let mut matches = 0; for _ in 0..40_000_000 { a = (a * 16807) % 2147483647; b = (b ...
true
3bc7fe5c4b9a8aa1982daf6fa62e7ee97475a2ed
Rust
kdy1/deno_lint
/src/rules/no_cond_assign.rs
UTF-8
5,094
3.015625
3
[ "MIT" ]
permissive
// Copyright 2020 the Deno authors. All rights reserved. MIT license. use super::{Context, LintRule}; use swc_common::Span; use swc_ecmascript::ast::Expr; use swc_ecmascript::ast::Expr::{Assign, Bin, Paren}; use swc_ecmascript::ast::Module; use swc_ecmascript::visit::{Node, Visit}; use std::sync::Arc; pub struct NoCo...
true
6cd3277ee99f0f847324825c9c7c213c15be7310
Rust
w1r2p1/rust-trailer
/src/presenters/order.rs
UTF-8
379
2.828125
3
[]
no_license
use models::*; // use presenters::*; #[derive(Debug, Clone)] pub struct OrderPresenter { pub order: Order, pub btc_value: f64, } impl OrderPresenter { pub fn current_value_in_btc(&self) -> f64 { self.order.qty * self.order.price } pub fn current_value_in_usd(&self) -> f64 { ...
true
72d8d0592ab48fab049cb51d59c541818c192bbc
Rust
Fadi88/AoC
/2021/day04/main.rs
UTF-8
1,160
3.03125
3
[ "Unlicense" ]
permissive
use std::fs::*; use std::io::Read; use std::time; fn bench(f: fn()) { let t0 = time::Instant::now(); let ret = f(); println!("time used {:?}", time::Instant::now().duration_since(t0)); ret } fn part_1() { let mut buf = String::new(); File::open("day04/input.txt") .unwrap() .re...
true
8adfade99a87c9c2d38c711749fffa86d6e17b35
Rust
oysterpack/oysterpack-smart-near
/near/oysterpack-smart-near/src/component/manages_account_data.rs
UTF-8
367
2.609375
3
[ "MIT" ]
permissive
use crate::domain::StorageUsage; /// Components that manage account data must implement this trait. /// When the contract is deployed this is used to set the minimum storage required for the account /// to register. pub trait ManagesAccountData { /// returns the minimum account storage required by this component ...
true
27e30dc8b4cbef35953332aa3e166146868fe4a7
Rust
Adoliin/move-links
/src/main.rs
UTF-8
2,147
2.859375
3
[ "MIT" ]
permissive
use move_links::Config; mod cli_utils; mod paths; use paths::Paths; use clap::{App, Arg}; use std::process; fn main() { let matches = get_matches(); let links_dir_raw = matches.value_of("LINKS_DIRECTORY").unwrap(); let src_path_raw = matches.value_of("SOURCE").unwrap(); let dest_path_raw = matches.val...
true
32a31ff7337594edbc017bb8a906d157d728b7e4
Rust
sohilladhani/rust_lang
/chapter_03/exercises/fibonacci/src/main.rs
UTF-8
866
3.75
4
[]
no_license
use std::io; fn nth_fibonacci(n: usize) -> usize { if n <= 1 { return n; } else { return nth_fibonacci(n-1) + nth_fibonacci(n-2); } } fn main() { loop { println!("Please enter n: "); let mut n = String::new(); io::stdin().read_line(&mut n).expect("Failed to re...
true
ba75c5d9ecf80e0dfbc11f4071477f319df62dd9
Rust
yupferris/advent-of-code-2015
/Day 08/problem-a/src/main.rs
UTF-8
1,151
3.09375
3
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![feature(iter_arith)] use std::io::Read; use std::fs::File; fn main() { let mut f = File::open("../input.txt").unwrap(); let mut s = String::new(); f.read_to_string(&mut s).ok(); let s = s; let answer: i32 = s.lines().map(|x| { let char_num = x.len() as i32; let mut chars_in_me...
true
33ce7f1349762de3df3c5f0d14400e0801227cf1
Rust
jlgerber/pbgui
/pbgui/src/messaging/event/main_toolbar.rs
UTF-8
1,258
3.15625
3
[]
no_license
//! Provides the MainToolbar enum, which implements the ToEvent, ToQString, and FromQString traits use super::*; #[derive(Debug, PartialEq)] pub enum MainToolbar { GetShows, GetRoles, GetPlatforms, GetSites, } impl ToEvent for MainToolbar { fn to_event(self) -> Event { Event::MainToolbar(s...
true
87bb2fe01b8e6739ddae1f438d63367f03d8507e
Rust
elpiel/ray-tracing
/src/object.rs
UTF-8
1,636
3.296875
3
[]
no_license
use crate::hitable::{HitRecord, Hitable}; use crate::Ray; use crate::Vec3; pub struct Sphere { pub center: Vec3, pub radius: f64, } impl Sphere { pub fn new(center: Vec3, radius: f64) -> Self { Self { center, radius } } } impl Hitable for Sphere { fn hit(&self, ray: &Ray, t_min: f64, t_ma...
true
9b9df92f1dbff9eb7660c34ded8d01f412f54282
Rust
mrzaid/Rust-Web-Assembly
/Assignment02/part02/q05/src/main.rs
UTF-8
902
3.21875
3
[]
no_license
use std::io; fn main() { println!("{}",eligibility()); } fn eligibility()->String{ let tot_marks = 180; println!("input the marks obtained in Physics"); let mut input1 = String::new(); io::stdin().read_line(&mut input1); let input1:i32 = input1.trim().parse().unwrap(); println!("input ...
true
6c2cf8933317086f8938499af6f9b92fb24b89db
Rust
tmsvdb/ggez_game
/src/old/components.rs
UTF-8
1,977
2.875
3
[]
no_license
use ggez::graphics; use ggez::graphics::{ DrawParam, Rect, Point2}; //use ecs; /// COMPONENT pub struct Components { pub debug: Option<DebugStats>, pub navigation: Option<Navigation>, pub selection: Option<Selection>, pub spritesheet: Option<Spritesheet>, } impl Default for Components { fn default() -> Compone...
true
1f9e76685ce48d9af12c52839dff00437d138eb9
Rust
kornelski/rexif
/src/main.rs
UTF-8
988
3.203125
3
[ "MIT" ]
permissive
use std::env; use std::process; use rexif::ExifTag; /// Tries to extract EXIF data from all files passed as CLI parameters, /// assuming that the files contain images. fn main() { let args: Vec<_> = env::args().collect(); if args.len() < 2 { eprintln!("Usage: {} image1 image2 ...", args[0]); p...
true
87b2d7543094360faf9ed9c3aa85a58e46b8884d
Rust
dgllghr/socks-async
/src/server.rs
UTF-8
9,187
2.640625
3
[]
no_license
pub use super::auth::*; pub use super::common::*; use std; use std::collections::HashSet; use std::convert::TryFrom; use std::net::SocketAddr; use std::time::Duration; use tokio::io; use tokio::net::{TcpListener, TcpStream}; use tokio::prelude::*; #[derive(Clone)] pub struct Server<A: Clone, C: Clone> { auth: A, ...
true
8949d3921e1510c962fdd278f10bb5f88de96e6b
Rust
mattmacy/TBA2
/src/autograd/variable.rs
UTF-8
1,816
2.53125
3
[ "BSD-2-Clause" ]
permissive
use autograd::function::*; use tensor::Tensor; use ::*; pub type VarList<T> = Vec<Variable<T>>; pub struct VariableImpl<T> { data: Tensor<T>, grad_fn: OptRcMut<Function<T>>, grad: OptRcMut<Variable<T>>, // version_counter etc ... } impl<T> VariableImpl<T> { fn new(data: Tensor<T>) -> Self { ...
true
328ec1a57561544ce25449cd83812cc28063f080
Rust
Nineball54/file-size-distro
/src/main.rs
UTF-8
5,703
3.328125
3
[ "MIT" ]
permissive
use std::fmt; use std::error::Error; use std::{env, io, time}; use std::marker::PhantomData; use std::path::{Path, PathBuf}; use walkdir::{DirEntry, WalkDir}; fn main() -> Result<(), Box<dyn Error>> { let start = time::Instant::now(); let args: Vec<String> = env::args().collect(); let root = parse_path(&a...
true
53de8bfe42d2b8d6db6121c3ea23d70efde64d40
Rust
sigmaSd/IRust
/crates/irust/src/main.rs
UTF-8
3,234
2.640625
3
[ "MIT" ]
permissive
mod args; mod dependencies; mod irust; mod utils; use crate::irust::IRust; use crate::{ args::{handle_args, ArgsResult}, irust::options::Options, }; use crossterm::{style::Stylize, tty::IsTty}; use dependencies::{check_required_deps, warn_about_opt_deps}; use irust_repl::CompileMode; use std::process::exit; fn...
true
5993be6fa8f7df84be2a21ad4b011f7fa9748b98
Rust
Kowalevskaja/nalgebra
/src/core/decompositions.rs
UTF-8
12,911
2.734375
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
use std::cmp; use alga::general::Real; use core::{SquareMatrix, OwnedSquareMatrix, ColumnVector, OwnedColumnVector}; use dimension::{Dim, Dynamic, U1}; use storage::{Storage, OwnedStorage}; use allocator::{Allocator, OwnedAllocator}; impl<N, D: Dim, S> SquareMatrix<N, D, S> where N: Real, S: OwnedStor...
true
567dae317b8f1493a214e1adfd9fee398e0e0bce
Rust
jgraef/amethyst_voxelmap
/src/storage.rs
UTF-8
2,280
3.109375
3
[ "MIT" ]
permissive
use std::convert::TryInto; use amethyst_core::math::{ Point3, Vector3, }; use crate::{ bounds::Bounds, map::CoordinateEncoder, Voxel, }; /// Trait that provides access to voxels. You can use [`VecStorage`] to store /// the voxels in an array in-memory, or implement your own provider (e.g. by /// ...
true
1d64778c618831ba96411797450a46e7f2ef9d60
Rust
bouzuya/rust-social-bookmarking
/src/use_case/update_mail_address_use_case.rs
UTF-8
1,831
2.671875
3
[]
no_license
use crate::entity::MailAddress; use crate::repository::CredentialRepository; use crate::service::{SendMailService, SessionService}; use anyhow::{anyhow, Result}; use std::sync::Arc; pub struct UpdateMailAddressUseCase { credential_repository: Arc<dyn CredentialRepository>, session_service: Arc<dyn SessionServi...
true
d7e125e879ce3c88c70ffb2f13be6115f2eb6349
Rust
sirkibsirkib/expr_tree_store
/src/main.rs
UTF-8
5,523
2.96875
3
[]
no_license
use one_to_many_map::OneToManyMap; use std::{ collections::{HashMap, HashSet}, hash::{Hash, Hasher}, }; #[derive(Copy, Clone, Eq, PartialEq, Hash)] #[repr(transparent)] pub struct DataId(u64); #[derive(Copy, Clone, Eq, PartialEq, Hash)] #[repr(transparent)] pub struct ExprId(u64); #[derive(Debug, Default)] p...
true
d28430bed84cff45d3fad389c0787b281d1d210c
Rust
lemonrock/context-coroutine
/src/context/TypeSafeTransfer.rs
UTF-8
3,616
3.046875
3
[ "MIT" ]
permissive
// This file is part of context-coroutine. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/context-coroutine/master/COPYRIGHT. No part of context-coroutine, including this file, may be copied, modified, pro...
true
eff00bbdcb5eb68fc4a4935b721b12842d2d28fb
Rust
ruma/ruma
/crates/ruma-client-api/src/filter/create_filter.rs
UTF-8
3,212
2.75
3
[ "MIT" ]
permissive
//! `POST /_matrix/client/*/user/{userId}/filter` //! //! Create a new filter for event retrieval. pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3useruseridfilter use ruma_common::{ api::{request, response, Metadata}, ...
true
2b273799e161440bfbfd628ea6f58ff0d6e58de3
Rust
petgraph/petgraph
/src/graph_impl/stable_graph/mod.rs
UTF-8
66,519
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
//! `StableGraph` keeps indices stable across removals. //! //! Depends on `feature = "stable_graph"`. //! use std::cmp; use std::fmt; use std::iter; use std::marker::PhantomData; use std::mem::replace; use std::mem::size_of; use std::ops::{Index, IndexMut}; use std::slice; use fixedbitset::FixedBitSet; use crate::{...
true
66c87290e58b5d8f51b961c6684c7b24cdc5127d
Rust
josnelihurt/rust-stuff
/simple-rust-gaming/src/engine/sdl_handler.rs
UTF-8
4,627
2.75
3
[]
no_license
use sdl2::EventPump; use std::collections::hash_map::HashMap; use std::vec::Vec; extern crate sdl2; use sdl2::image::LoadTexture; use sdl2::render::TextureCreator; use sdl2::video::WindowContext; use sdl2::{event::Event, image::InitFlag, keyboard::Keycode, render::Canvas, video::Window}; use crate::engine::basic_ty...
true
77c2caf83050723e2a98f7b1e1320bf3fca5c0b6
Rust
arnodb/torus_trooper_rs
/src/tt/actor/particle.rs
UTF-8
10,076
2.546875
3
[ "BSD-2-Clause" ]
permissive
use std::ops::{Index, IndexMut}; use crate::gl; use crate::tt::actor::pool::{Pool, PoolActorRef}; use crate::tt::screen::Screen; use crate::tt::tunnel::{InCourseSliceCheck, Tunnel}; use crate::util::color::Color; use crate::util::rand::Rand; use crate::util::vector::{Vector, Vector3}; const GRAVITY: f32 = 0.02; cons...
true
4e011a4b164573fd2f936d99806e40a2a1b36069
Rust
PatrickNorton/rust-runtime
/src/custom_types/slice.rs
UTF-8
5,599
2.765625
3
[]
no_license
use crate::custom_types::exceptions::value_error; use crate::custom_types::range::Range; use crate::custom_var::CustomVar; use crate::int_var::IntVar; use crate::method::StdMethod; use crate::name::Name; use crate::operator::Operator; use crate::runtime::Runtime; use crate::std_type::Type; use crate::string_var::String...
true
2a7e543134eae57d0084efa9101c826f8871d366
Rust
jgouly/cube-tools
/cube/src/alg/parser.rs
UTF-8
10,501
3.09375
3
[ "MIT" ]
permissive
use crate::alg::{Alg, Amount, Direction, Face, Move, Rotation, Slice, Width}; use std::convert::TryFrom; #[derive(Debug)] #[cfg_attr(test, derive(PartialEq))] pub struct ParseError; fn split_first(a: &str) -> Option<(char, &str)> { let mut chars = a.chars(); chars.next().map(|c| (c, chars.as_str())) } fn parse_m...
true
fced3d60bd58849708a502934dc2d0892f4ccd35
Rust
ethankhall/release-manager
/src/manager_lib/commands/local.rs
UTF-8
4,340
2.703125
3
[ "BSD-2-Clause" ]
permissive
use std::time::{SystemTime, UNIX_EPOCH}; use clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, SubCommand}; use semver::Identifier; use semver::Version as SemverVersion; use super::super::config::Config; use super::super::errors::*; use super::super::version_manager::build_project; pub fn project_clap<'a, 'b>() ->...
true
e36a5295d3aa4ceef7fd6d1edd1927a72589d1b4
Rust
jduan/cosmos
/rust_sandbox/rust_sandbox/src/constants.rs
UTF-8
1,245
3.75
4
[ "MIT" ]
permissive
/// Rust has two different types of constants which can be declared in any scope including global. /// Both require explicit type annotation: /// /// 1. const: An unchangeable value (the common case). /// 2. static: A possibly mutable variable with 'static lifetime. The static lifetime is inferred /// and does no...
true
cb452f6149d1398505b50f8cf98887c32ce2df73
Rust
ashutoshlamba/ECE421-GroupProject1
/connect4/connect4-web/src/views/statistics.rs
UTF-8
2,271
2.640625
3
[]
no_license
use yew::prelude::*; use yew::virtual_dom::VNode; use crate::components::MenuButtonLight; use crate::coms; use connect4_coms::types::GameStats; use wasm_bindgen_futures::spawn_local; pub struct Statistics { stats: GameStats, } #[derive(Debug)] pub enum Msg { UpdateStats(GameStats), } impl Component for Stat...
true
a65d366115d08840cf09c911d23dfe3d97abad61
Rust
qoollo/bob
/bob-apps/bin/config_cluster_generator/center.rs
UTF-8
19,133
2.609375
3
[ "MIT" ]
permissive
#![allow(clippy::ptr_arg)] use anyhow::{anyhow, Result as AnyResult}; use bob::{ ClusterConfig, ClusterNodeConfig as ClusterNode, ClusterRackConfig as ClusterRack, ReplicaConfig as Replica, VDiskConfig as VDisk, }; use std::{ collections::{HashMap, HashSet}, ops::AddAssign, }; const REPLICA_IN_FIRST_RA...
true
b54cd0918a33022e8f2b5b2220422adb55817e54
Rust
EFanZh/LeetCode
/src/problem_0637_average_of_levels_in_binary_tree/bfs.rs
UTF-8
1,694
3.03125
3
[]
no_license
use crate::data_structures::TreeNode; pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::cell::RefCell; use std::collections::VecDeque; use std::rc::Rc; impl Solution { #[allow(clippy::cast_precision_loss)] p...
true
d594afa3cb354f7cb63a467d45f5a1765ccae9ae
Rust
marcomeyer/EDU-rust
/s6/barycenter-parallel-rs/src/main.rs
UTF-8
1,557
3
3
[]
no_license
extern crate rayon; extern crate itertools; use rayon::prelude::*; use itertools::Itertools; mod bodies; use bodies::get_values; #[derive(Debug, Clone, Copy)] pub struct Body { x: f64, y: f64, z: f64, mass: f64, } impl Body { fn new(x: f64, y: f64, z: f64, mass: f64) -> Body { Body { ...
true
fae59dfaa2b1cdcb9f0610d10a16490f831be18b
Rust
swfsql/leetcode
/tests/_1302_deepest_leaves_sum.rs
UTF-8
566
3.015625
3
[]
no_license
use leetcode::_1302_deepest_leaves_sum::*; use std::cell::RefCell; use std::rc::Rc; fn node( val: i32, left: Option<Rc<RefCell<TreeNode>>>, right: Option<Rc<RefCell<TreeNode>>>, ) -> Option<Rc<RefCell<TreeNode>>> { Some(Rc::new(RefCell::new(TreeNode { val, left, right }))) } #[test] fn _1302_deepest_l...
true
63ea247a2dc8a05957f881d2e5c906c522c28526
Rust
Gogopex/UnicornConsole
/unicorn/src/plugins/duktape/src/errors.rs
UTF-8
2,346
3.203125
3
[ "MIT" ]
permissive
use std::error::Error; use std::fmt; use std::result::Result; use ffi::*; /// These are the standard error codes, which make it easy to return /// pre-defined errors from duktape functions implemented in Rust. #[derive(Clone, Debug, PartialEq, Eq)] #[repr(i32)] pub enum ErrorCode { None = DUK_ERR_NONE, Error =...
true
68516fecdf2f4ece1eb0e8f0d6abcd1cb004ff8a
Rust
zolkko/rust-katas
/src/read_ints.rs
UTF-8
886
2.828125
3
[]
no_license
#[macro_use] extern crate ndarray; fn main() { let mut line = String::with_capacity(10); std::io::stdin().read_line(&mut line).expect("expect the line of text"); let input = line.trim_right(); let sum = input.split(' ') .flat_map(|x| x.parse::<i32>().ok()) .fold(0i32, |a, b| a + b); ...
true
b678bbf1e6d7f0e13df0258ea14e5539147ae16a
Rust
alekseysidorov/simple-clock
/src/lib.rs
UTF-8
2,403
3.46875
3
[ "MIT" ]
permissive
//! This library provides a very simple system clock interface with microsecond precision. //! Unlike the [`embedded-time`](https://crates.io/crates/embedded-time), //! the interface provided by this library is as simple as possible which is better suited //! for writing prototypes. #![cfg_attr(not(test), no_std)] #[...
true
eb5efd06d44b9ababfc35e4bc78807cbe9453d56
Rust
dhalf/melange
/src/tensor/mod.rs
UTF-8
22,819
2.953125
3
[]
no_license
//! Collection of tools to interact with multidimensional arrays that are at the //! core of ML pipelines. //! //! It defines various ways to store data and optimized mathematical operations. //! //! Contrary to other ndarray modules such as numpy in Python or ndarray in Rust, //! this module allows full size checking ...
true
7daa694768998a95c9d44fc0349416b5bc77ff2e
Rust
pes-magic/procon
/AtCoder/AGC033/C.rs
UTF-8
820
3.140625
3
[]
no_license
use std::io::Read; fn far(g: &Vec<Vec<usize>>, pos: usize, prev: usize, cur: usize) -> (usize, usize) { let mut res = (cur, pos); for &t in &g[pos] { if t == prev { continue } res = std::cmp::max(res, far(g, t, pos, cur+1)); } res } fn main() { let mut buf = String::new(); std:...
true
be1017d4d226e2650856be840b785323dbf04ebe
Rust
LukasKalbertodt/jswag
/src/java/inner.rs
UTF-8
1,688
3.0625
3
[ "MIT" ]
permissive
use std::process::{Command, ExitStatus}; use std::path::Path; use std::io; use super::{JAVAC_NAME, JAVA_NAME}; use job::Job; /// Calls `javac` with the given file pub fn compile(file: &Path, job: &Job) -> Result<(), Error> { // Print what we are about to do if job.verbose { msg!(Running, "`{} {}`", JA...
true
1cca6f7e139c201fedc872e75981acce9489470c
Rust
Sybl-ml/quic-iterators
/src/server.rs
UTF-8
3,244
2.640625
3
[]
no_license
use std::fs; use std::net::{SocketAddr, SocketAddrV4}; use std::str::FromStr; use std::sync::Arc; use futures::StreamExt; use quinn::Endpoint; mod buffer; mod row; use buffer::Buffer; use row::Row; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; fn main() { if let Err(e) = run() { ...
true
ab590164172b7cf35fb240009f721f1ee78d6ba1
Rust
tail-island/water-jug-problem
/src/beam_search.rs
UTF-8
4,020
3.421875
3
[]
no_license
use std::collections::*; use std::cmp::*; use super::game::*; // 次の解答を取得します。clone()してpush()するだけでもよいのですけど、少しだけ、メモリ効率を考えてみました。 fn next_answer(answer: &[Action], action: &Action) -> Vec<Action> { let mut result = Vec::with_capacity(answer.len() + 1); result.extend_from_slice(answer); result.push(action.clone...
true
ecd591663121d910ea59fd6d7821a075fe0c475f
Rust
dennisss/dacha
/pkg/xml/src/lib.rs
UTF-8
1,437
2.953125
3
[ "Apache-2.0" ]
permissive
pub mod spec; mod syntax; use common::errors::*; pub use spec::*; fn pretty_print_parsing_error(input: &str, remaining_bytes: usize) { let target_i = input.len() - remaining_bytes; let mut line_number = 1; let mut line_start = 0; let mut line_end = None; for (idx, c) in input.char_indices() { ...
true
9be12ffb269255d36065d1e489e616169bd25130
Rust
dashscript/dashscript
/cli/src/main.rs
UTF-8
628
2.671875
3
[]
no_license
pub mod run; pub mod command; // pub mod repl; use command::Cli; use std::fs::read_to_string; use std::path::PathBuf; pub fn read_file(fname: PathBuf) -> Result<String, std::io::Error> { Ok(String::from(read_to_string(fname)?)) } pub fn main() { let mut command = Cli::new(); match command.args.get(1) { ...
true
0b57301d38f799b6e3aeba16531976a47a485271
Rust
DanBrezeanu/hzgrow-r502
/src/utils.rs
UTF-8
1,548
3.453125
3
[ "MIT" ]
permissive
/// Allows a type to define how to deserialise itself from some bytes pub trait FromPayload { fn from_payload(payload: &[u8]) -> Self; } /// Something that lets you write commands (typically, a `R502`). pub trait CommandWriter { fn write_cmd_bytes(&mut self, bytes: &[u8]); } /// Allows a type to define how to...
true
1ca2c4e6c2b4ab2bc4f8db3809279b7047638aa6
Rust
rhazarian/ceres
/ceres-formats/src/object.rs
UTF-8
6,672
2.96875
3
[ "MIT" ]
permissive
use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; use crate::metadata::FieldVariant; use crate::metadata::MetadataStore; use crate::ObjectId; use crate::ObjectKind; use crate::parser::slk; use crate::ValueType; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum Value { String(...
true
a46e1d487c4d71ae51c12b49e8c548ab505ec165
Rust
simonvoelcker/rust-onitama
/src/db.rs
UTF-8
1,373
2.953125
3
[ "CC0-1.0" ]
permissive
use std::path::Path; use rusqlite::{params, Connection, Result}; fn open_db() -> Connection { let db_path = Path::new("./games_db.sqlite"); let conn = Connection::open(db_path).expect("Could not open DB connection"); conn.execute( "CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY, game TEXT N...
true
ffadcfe6ae544cc92bf1e9a2157b69e7886ff009
Rust
nathanfaucett/rs-gl_geometry
/src/gl_geometry.rs
UTF-8
9,168
3.0625
3
[ "MIT" ]
permissive
use collections::string::String; use vector::Vector; use stack::Stack; use collection::Collection; use hash_map::HashMap; use insert::Insert; use shared::Shared; use num::Num; use gl; use gl_context::{Context, Buffer, VertexArray}; use geometry::{Geometry, AttributeValue}; #[derive(Clone, Debug)] pub struct Buffe...
true
6fa0b3b496319511338344e027318acbc1a99918
Rust
bytecodealliance/wasmtime
/crates/wiggle/tests/strings.rs
UTF-8
10,033
2.796875
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
use proptest::prelude::*; use wiggle::{GuestMemory, GuestPtr}; use wiggle_test::{impl_errno, HostMemory, MemArea, MemAreas, WasiCtx}; wiggle::from_witx!({ witx: ["$CARGO_MANIFEST_DIR/tests/strings.witx"], }); impl_errno!(types::Errno); impl<'a> strings::Strings for WasiCtx<'a> { fn hello_string(&mut self, a_...
true
6b6880c0ee58a1ef6218c0507a697db84e067ae5
Rust
hudson-ayers/tock
/boards/components/src/sched/cooperative.rs
UTF-8
1,889
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Component for a cooperative scheduler. //! //! This provides one Component, CooperativeComponent. //! //! Usage //! ----- //! ```rust //! let scheduler = components::cooperative::CooperativeComponent::new(&PROCESSES) //! .finalize(components::coop_component_helper!(NUM_PROCS)); //! ``` // Author: Hudson Ayers ...
true
aa5c932e1cb319d6d4b47a1e5b933ed5a8151bd7
Rust
sinvalmendes/learning-rust
/src/14/closures/src/main.rs
UTF-8
498
3.671875
4
[]
no_license
fn main() { let closure = |a| { // defining a closure called "closure" that receives parameter "a" println!("{}", a); }; let b = String::from("this is b"); closure(b); call_function(callback, "this is the value of 'text' parameter comming from main calling 'call_function' passing 'callback...
true
9f9d563bd4aeff9b2b0523a403b4e149f7317cb3
Rust
darach/value-trait
/src/object.rs
UTF-8
4,825
3.609375
4
[ "MIT", "Apache-2.0" ]
permissive
use halfbrown::HashMap as Halfbrown; use std::borrow::Borrow; use std::collections::HashMap; use std::hash::Hash; /// A JSON Object pub trait Object { /// The key in the objects type Key; /// The values in the object type Element; /// Gets a ref to a value based on a key, returns `None` if the ...
true
938ab4ada002d021bd8cb8e26f5b81fe94060121
Rust
codepitbull/wifi_qr
/src/main.rs
UTF-8
3,185
2.671875
3
[]
no_license
extern crate qrcodegen; use qrcodegen::QrCode; use qrcodegen::QrCodeEcc; extern crate chrono; use chrono::{Datelike, Timelike, Utc}; use std::fs::File; use std::io::Write; use std::process::Command; use std::env; extern crate rand; use rand::{thread_rng, Rng}; use rand::distributions::Alphanumeric; static HTML_TEMP...
true
ab06a93e768d61232c06fbeedc738f7ac2478059
Rust
aalouaoui/balls-simulation
/src/main.rs
UTF-8
1,306
2.546875
3
[]
no_license
use macroquad::prelude::*; mod ball; use ball::Ball; fn window_conf() -> Conf { Conf { window_title: "Balls Simulation".to_owned(), sample_count: 2, high_dpi: true, ..Default::default() } } #[macroquad::main(window_conf)] async fn main() { let mut balls: Vec<Ball> = vec![]...
true
6b9ed2af5f27708a96b53de200ae8cb1fb29474f
Rust
mikebaumgart/process-queue
/src/server.rs
UTF-8
7,406
2.703125
3
[ "MIT" ]
permissive
use anyhow::{bail, Result}; use log::{error, info}; use std::collections::HashMap; use std::sync::Arc; use tokio::net::{UnixListener, UnixStream}; use tokio::sync::Mutex; use crate::connection::Connection; use crate::request::{self, Request}; use crate::response::{self, Response}; use crate::sync::{condition, DropGuar...
true
c17be9160145ed8775b7b995848ed0b6d1e0a39f
Rust
mzgoddard/tessel-audio-graph
/graph_nodes/src/gated.rs
UTF-8
2,589
2.828125
3
[]
no_license
use std::time::Instant; use std::sync::{Arc, Mutex}; use graph_utils::{Callback, CallbackInner, RingBuffer}; #[derive(Clone)] pub struct GateState(Arc<Mutex<bool>>); pub struct Gated(Callback); #[derive(Clone)] pub struct SwitchState(Arc<Mutex<usize>>); pub struct Switched(Callback); impl GateState { pub fn n...
true
cacc4f7867c9f09d6f80b5737b443b3ed6c72315
Rust
BanBuDu0/Simple-KV
/src/client.rs
UTF-8
10,281
2.75
3
[]
no_license
extern crate grpcio; extern crate proto; use std::io; use std::io::prelude::*; use std::sync::{Arc, Mutex}; use grpcio::{ChannelBuilder, EnvBuilder}; use proto::kvraft::{DeleteArgs, GetArgs, PutArgs, ScanArgs}; use proto::kvraft_grpc::KvRaftClient; use std::sync::mpsc::RecvTimeoutError; use std::time::Instant; fn r...
true
6772b95ff95c0192036095eea5c1293edb62ce44
Rust
unsignedbytebite/permutate
/src/list_wrapper/tuple_of_lists.rs
UTF-8
3,703
2.96875
3
[ "MIT" ]
permissive
use ListWrapper; // reference: https://doc.rust-lang.org/src/core/tuple.rs.html macro_rules! tuple_impls { ($( $Tuple:ident { $(($idx:tt) -> $T:ident)+ } )+) => { $( impl<'a, $($T),+> ListWrapper<($($T,)+)> for ($(&'a [$T],)+) where $(...
true
9f6f5d7738e3cf9252ed8896b0d0f9ee886f0e58
Rust
HerringtonDarkholme/leetcode
/src/1510_winner_square_game.rs
UTF-8
774
3.03125
3
[]
no_license
impl Solution { pub fn winner_square_game(n: i32) -> bool { let mut dp = vec![None; n as usize + 1]; dp[0] = Some(false); let squares = find_squares(n); run(n, &squares, &mut dp) } } fn find_squares(n: i32) -> Vec<i32> { let mut ret = vec![]; let mut i = 1; while i *...
true
24010fe581ae2ca3ecc745272fafb0f7dbd34684
Rust
iCodeIN/swindon
/src/logging/http.rs
UTF-8
3,136
2.59375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::fmt; use std::net::SocketAddr; use tk_http::Status; use tk_http::server::Head; use trimmer::{Variable, Var, DataError, Output}; use crate::request_id::RequestId; use crate::logging::context::{Context, AsContext}; pub struct EarlyRequest<'a> { pub addr: SocketAddr, pub head: &'a Head<'a>, pub re...
true
37438385235837d09c5bb0e7b5fd746a482f0f91
Rust
rune-rs/rune
/crates/rune-modules/src/experiments.rs
UTF-8
1,717
2.6875
3
[ "MIT", "Apache-2.0" ]
permissive
//! `std::experiments` module for the [Rune Language]. //! //! [Rune Language]: https://rune-rs.github.io //! //! ## Usage //! //! Add the following to your `Cargo.toml`: //! //! ```toml //! rune-modules = { version = "0.12.3", features = ["experiments"] } //! ``` //! //! Install it into your context: //! //! ```rust /...
true
058b409777e88ac2a2c5e0f3e202b556c541a355
Rust
borman/gimli
/tests/parse_self.rs
UTF-8
4,362
2.65625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate gimli; use gimli::{AttributeValue, DebugAbbrev, DebugAranges, DebugInfo, DebugLine, DebugPubNames, DebugPubTypes, DebugStr, LittleEndian}; use std::env; use std::fs::File; use std::io::Read; use std::path::PathBuf; fn read_section(section: &str) -> Vec<u8> { let mut path = PathBuf::new();...
true
6bafc6d288f3473da55feae411a3bc86d4f3135c
Rust
bluejekyll/hyper-proxy
/src/lib.rs
UTF-8
11,015
2.859375
3
[ "MIT" ]
permissive
//! A Proxy Connector crate for Hyper based applications //! //! # Example //! ```rust,no_run //! extern crate hyper; //! extern crate hyper_proxy; //! extern crate futures; //! extern crate tokio_core; //! //! use hyper::{Chunk, Client, Request, Method, Uri}; //! use hyper::client::HttpConnector; //! use hyper::header...
true
2e4d7f23424da225a785006dd0380c861160463b
Rust
gufoe/gupier
/src/server.rs
UTF-8
3,439
3.0625
3
[]
no_license
use crate::com::Channel; use serde_derive::{Deserialize, Serialize}; use std::collections::HashMap; use crate::util; use crate::gameplay::GameplayHost; use std::net::SocketAddr; #[derive(Clone, Debug, Serialize, Deserialize)] #[allow(dead_code)] pub struct Player { pub id: usize, pub addr: SocketAddr, pu...
true
adbec015b4c6ffde56bfe492a3e311465674d6dc
Rust
DirtGrubDylan/terminal_cribbage
/src/cards/deck.rs
UTF-8
6,489
3.8125
4
[ "MIT" ]
permissive
use std::fmt; use itertools::Itertools; use rand::seq::SliceRandom; use cards::{Card, Rank, Suit}; /// The [`Deck`] struct is a wrapper for a vector of [`Card`]s. /// /// This wrapper is so the vector can be treated like an actual deck of [`Card`]s #[derive(Debug, PartialEq, Clone)] pub struct Deck(Vec<Card>); impl...
true
c30cc2d1d5571f33ed1de590ff578bd36bd6b9c5
Rust
sdbx/minda
/server/game-server/src/game/cord.rs
UTF-8
2,405
3.03125
3
[]
no_license
use serde::Serializer; use serde::Serialize; use serde::ser::SerializeStruct; use std::iter::FromIterator; use std::collections::VecDeque; use std::cmp::max; use std::ops; #[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Debug)] pub struct Cord(pub isize, pub isize, pub isize); impl Cord { const zero: Cor...
true
87402e8f17cc6b5428d0df66961afc850ccc0f20
Rust
lightdiscord/dungeons
/io/src/macros/packets.rs
UTF-8
4,552
2.984375
3
[ "MIT" ]
permissive
#[macro_export] macro_rules! packets { ( $(#[$enum_meta:meta])* common { $($packet:ident),+ } ) => { $(#[$enum_meta])* #[derive(Debug)] pub enum Packet { $($packet($packet)),* } }; ( $(#[$enum_meta:meta])* s...
true
b088638913990b91fd90b842426f9dabbdefe46b
Rust
nrabulinski/advent-of-code-2019
/day1/part1.rs
UTF-8
345
2.6875
3
[]
no_license
use std::{ io::{BufReader, prelude::*}, fs::File, }; fn main() { let input = File::open("input").unwrap(); let input = BufReader::new(input); let modules = input.lines().filter_map(|module| module.unwrap().parse::<i32>().ok()); let fuels = modules.map(|module| module / 3 - 2); println!("{}"...
true
38d87bd9a7bc95771ed15b20511c6aadeffddc1c
Rust
bnicholson/rust-learning
/src/main.rs
UTF-8
1,811
2.6875
3
[]
no_license
mod print; mod vars; mod types; mod strings; mod tuples; mod arrays; mod vectors; mod conditionals; mod loops; mod functions; mod pointers_ref; mod structs; mod enums; mod cli; fn main() { println!("---------- Start --------------------------"); println!("Hello, utc universe"); let now = chrono::Local::no...
true
ae62190816fd5fdde3dce25ce9d72b6331c2d253
Rust
simongarisch/300-Project-Euler
/exercises/Ex021/rust_ex021/src/main.rs
UTF-8
540
3.734375
4
[]
no_license
fn sum_divisors(x: i64) -> i64 { let mut sum: i64 = 0; for i in 1..x { if (x % i) == 0 { sum += i; } } return sum; } fn is_amicable(x: i64) -> bool { let sum_divx: i64 = sum_divisors(x); if sum_divx == x { return false; } if sum_divisors(sum_divx) ==...
true
73ff6d2223c76bf5fd0632090dee013bce69cb86
Rust
awriterish/findtext
/src/main.rs
UTF-8
600
3.078125
3
[]
no_license
use std::env; use std::fs; fn findInFile(lookFor:String, files:Vec<String>) { for file in files { let data = fs::read_to_string(file).expect("Unable to read file"); let split = data.split("\n"); for s in split { if s.contains(&lookFor) { println!("{}", s); ...
true
e68ec8111cf7f5c54d437be5a49d152f0874959e
Rust
jonhoo/fantoccini
/src/wd.rs
UTF-8
10,655
3.265625
3
[ "Apache-2.0", "MIT" ]
permissive
//! WebDriver types and declarations. use crate::error; #[cfg(doc)] use crate::Client; use http::Method; use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::convert::TryFrom; use std::fmt; use std::fmt::Debug; use std::time::Duration; use url::{ParseError, Url}; use webdriver::command::TimeoutsParamete...
true
0c72818da83d2ff61ec46cbc692ac7cf72adee83
Rust
rarescosma/eldiro
/crates/too-many-lists/src/first.rs
UTF-8
2,473
3.765625
4
[ "MIT" ]
permissive
use std::mem; pub enum FunList { Empty, Elem(i32, Box<List>), } /// Avoids allocating the Empty case, reducing the total number of /// heap allocations by 1. /// /// But... loses out on null pointer optimization pub enum AnotherList { Empty, ElemThenEmpty(i32), ElemThenNotEmpty(i32, Box<List>), } ...
true
2253f7f5b9e17aa99668d9c3de0b8d04eb23cc5f
Rust
turion/rust_signal_functions
/tests/mod.rs
UTF-8
497
3.0625
3
[]
no_license
use signal_functions::*; use signal_functions::accum::*; use signal_functions::fun::*; #[test] fn test() { let sum = Accum::new(0, |acc, input| *acc += input); let squares = Fun::new(|n| n * n); let doubles = Fun::new(|n| n * 2); let result: Vec<_> = sum .and_then(squares) .fan_out(doub...
true
00630f10360e213501077e68f5d384839f981f8a
Rust
detnon/rust
/examples/hashmaps_02/src/main.rs
UTF-8
870
3.625
4
[]
no_license
use std::collections::HashMap; fn main() { let field_name = String::from("Favourite Colour"); let field_value = String::from("Black"); let mut map = HashMap::new(); map.insert(field_name, field_value); // Accessing values in a HashMap let mut scores = HashMap::new(); scores.insert(String...
true
96d44591337ad32929faab9dbaf3122c9b2dafcc
Rust
hakonrossebo/raytracer-challenge
/src/bin/clock.rs
UTF-8
1,168
2.65625
3
[]
no_license
extern crate chrono; extern crate raytracer_challenge; use raytracer_challenge::canvas::Canvas; use raytracer_challenge::file::write_ppm_to_file; use raytracer_challenge::transformations; use raytracer_challenge::tuple::Tuple; use std::f64::consts::PI; fn main() { let canvas_width = 550; let canvas_height = 550; ...
true
b2ac90e292e812a6dfb32721097d8bc90a2c0311
Rust
DataxPL/dsp
/src/zip.rs
UTF-8
2,767
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::error::Error; use std::ffi::CString; use std::os::raw; use std::path::PathBuf; #[link(name = "zip")] extern { fn zip_open(path: *const raw::c_char, flags: raw::c_int, errorp: *mut raw::c_int) -> *mut raw::c_void; fn zip_file_add(archive: *mut raw::c_void, name: *const raw::c_char, source: *mut raw::c_...
true
1e1f5c02e38a800c8803f3c668b5c8dbe69e82d5
Rust
rclayton-the-terrible/bitmanip-rust
/src/bits_set.rs
UTF-8
2,732
3.734375
4
[]
no_license
pub fn division_bits_set(int: i64) -> u64 { let mut bits_set: u64 = 0; let mut rem: i64 = int; while rem > 0 { if rem % 2 == 1 { bits_set += 1; } rem = f64::floor((rem / 2) as f64) as i64 } bits_set } pub fn kernighans_bit_set(int: i64) -> u64 { let mut bits_...
true
0e1425e33b901d99cb24d74da3abc4872add90bd
Rust
ejmahler/iced
/src/pure/sandbox.rs
UTF-8
3,335
3.3125
3
[ "MIT" ]
permissive
use crate::pure; use crate::{Color, Command, Error, Settings, Subscription}; /// A pure version of [`Sandbox`]. /// /// Unlike the impure version, the `view` method of this trait takes an /// immutable reference to `self` and returns a pure [`Element`]. /// /// [`Sandbox`]: crate::Sandbox /// [`Element`]: pure::Elemen...
true
2f8c6033b8cb803ca834b62a80cf401c7726aa48
Rust
getong/laminar
/src/infrastructure/congestion.rs
UTF-8
2,300
3.203125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::time::Instant; use crate::{ net::{NetworkQuality, RttMeasurer}, sequence_buffer::{CongestionData, SequenceBuffer}, Config, }; /// Keeps track of congestion information. pub struct CongestionHandler { rtt_measurer: RttMeasurer, congestion_data: SequenceBuffer<CongestionData>, _quality:...
true
af32a2c8c4778bae6d43d08bb6022ed9739786f0
Rust
PlasmaPower/brute-force
/src/adaptors.rs
UTF-8
1,480
3.3125
3
[ "MIT" ]
permissive
use crate::Advance; /// Automatically advance the state by incrementing it. Note that you'll likely /// need to use this adaptor before others, as others assume the function takes /// a mutable input. pub fn auto_advance<S, R, F>(f: F) -> impl Fn(&mut S) -> R where S: Advance, F: Fn(&S) -> R, { move |s| { ...
true
20d9251badfa139f2f1401fb6b5ede8080b1065d
Rust
LevitatingOrange/circular-family-tree
/src/main.rs
UTF-8
5,111
2.5625
3
[]
no_license
mod circular_binary_tree; mod position; use svg::Document; use circular_binary_tree::*; use position::Position; use resvg::prelude::*; use std::path::PathBuf; use std::str::FromStr; use structopt::StructOpt; #[derive(Debug)] enum DIN { A0_4, A0_2, A0, A1, A2, A3, A4, A5, A6, A...
true
bcb98bdfc2b614a74b0eca2a9c527a9ffc300250
Rust
TheBambino/terry
/terraria-protocol/src/packets/gem_lock_toggle.rs
UTF-8
609
3.015625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::packets::PacketBody; use crate::SliceCursor; /// Toggle the gem lock. /// /// Direction: Client -> Server. #[derive(Debug)] pub struct GemLockToggle { pub x: i16, pub y: i16, pub on: bool, } impl PacketBody for GemLockToggle { const TAG: u8 = 105; fn write_body(&self, cursor: &mut Slic...
true
5f450183cf43c0f0af4eff47af30908d072a85df
Rust
dimforge/nalgebra
/src/proptest/mod.rs
UTF-8
16,778
3.640625
4
[ "Apache-2.0" ]
permissive
//! `proptest`-related features for `nalgebra` data structures. //! //! **This module is only available when the `proptest-support` feature is enabled in `nalgebra`**. //! //! `proptest` is a library for *property-based testing*. While similar to `QuickCheck`, //! which may be more familiar to some users, it has a more...
true
9c2516049bfd3531b7f4046622e2a2abd74ce85a
Rust
BooleanCat/safely
/libsafely/src/config/mount.rs
UTF-8
1,584
3.390625
3
[]
no_license
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct Mount { pub destination: String, #[serde(skip_serializing_if = "Option::is_none")] pub source: Option<String>, #[serde(skip_serializing_if = "Option::is_none")] pub options: Option<Vec<String>>, #[serde(...
true
057867027a110234565514baecac67b7c843ac56
Rust
zotho/test_monitor
/src/main.rs
UTF-8
2,380
2.859375
3
[]
no_license
use macroquad::prelude::*; fn window_conf() -> Conf { Conf { window_title: "Test monitor".to_owned(), // fullscreen: true, ..Default::default() } } #[derive(Debug, Default)] struct App { width: f32, height: f32, x: f32, y: f32, speed: f32, thickness: f32, te...
true
ce53c6db0737c8b6ad9a13f36e13604916eb584a
Rust
YoshikawaMasashi/toid
/src/high_layer_trial/num/mod.rs
UTF-8
1,792
2.90625
3
[]
no_license
use noise::{NoiseFn, Perlin}; use rand; use super::super::data::music_info::{Beat, Pitch}; pub fn parlin_noise_seq(size: usize, degree: f32, seed: Option<f32>) -> Vec<f32> { let mut seed = match seed { Some(seed) => seed, None => rand::random::<f32>(), }; let mut noise = vec![]; let p...
true
e38fb1c6b03cdcf43f23208334c8fdab8276a2e1
Rust
gottstech/gotts-oracle
/config/src/types.rs
UTF-8
3,921
2.65625
3
[ "Apache-2.0" ]
permissive
// Copyright 2018 The Grin Developers // Modifications Copyright 2019 The Gotts Developers // // 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...
true
a164943870403e9d70dd594bbe4fa569baeb8d55
Rust
marco-c/gecko-dev-wordified
/third_party/rust/half/src/bfloat.rs
UTF-8
48,348
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
# [ cfg ( feature = " bytemuck " ) ] use bytemuck : : { Pod Zeroable } ; use core : : { cmp : : Ordering fmt : : { Binary Debug Display Error Formatter LowerExp LowerHex Octal UpperExp UpperHex } iter : : { Product Sum } num : : { FpCategory ParseFloatError } ops : : { Add AddAssign Div DivAssign Mul MulAssign Neg Rem ...
true
ce74ffd733f373d0e9935a807e1643823b36b0c7
Rust
emirayka/nia_interpreter_core
/src/interpreter/stdlib/builtin_objects/list/take.rs
UTF-8
2,992
3.390625
3
[ "MIT" ]
permissive
use crate::interpreter::environment::EnvironmentId; use crate::interpreter::error::Error; use crate::interpreter::interpreter::Interpreter; use crate::interpreter::value::Value; use crate::interpreter::library; pub fn take( interpreter: &mut Interpreter, _environment: EnvironmentId, values: Vec<Value>, ) ...
true
ef7d46e7e97aa1ab9efd8ba3c53f8718b2dda76b
Rust
psychon/x11rb
/xcbgen-rs/src/defs/top_level.rs
UTF-8
24,374
2.84375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::cell::RefCell; use std::rc::{Rc, Weak}; use once_cell::unsync::OnceCell; use super::{ Alignment, BuiltInType, ComplexAlignment, Doc, Expression, ExternalParam, FieldDef, Namespace, }; /// Any kind of definition in a namespace. #[derive(Debug)] pub enum Def { /// A request definition. Request(Rc<...
true
c91b791300ecb0135c641ed4e7919b2032f91614
Rust
faineance/thermite
/src/lib/lexer.rs
UTF-8
4,637
3.625
4
[ "MIT" ]
permissive
use std::str::CharIndices; use std::iter::Peekable; #[derive(Debug, PartialEq)] pub enum Token { Identifier(String), Value(i32), } pub fn tokenize(input: &str) -> Vec<Token> { let mut lexer = Lexer::new(input); let mut output = vec![]; loop { match lexer.next() { Some(t) => { output.push(t); } ...
true
34b1e763e1c550dc3d57a5780e6e60fbea975ee8
Rust
Dano-Sato/Dano-Sato-s-code-jungle
/Rust/Third_Homework/src/main.rs
UTF-8
754
3.484375
3
[]
no_license
#[derive(Debug, Clone)] pub enum BinaryTree { Node { value: i32, leftTree: Box<BinaryTree>, rightTree: Box<BinaryTree>, }, Empty, } impl BinaryTree{ fn singleton(x: i32) ->BinaryTree{ BinaryTree::Node{ value: x, leftTree: Box::new(BinaryTree::...
true
d4004f7f1694c6e3dcf57dbaef8025edd235a0a1
Rust
maxmindlin/raytracing-in-one-weekend
/src/hittable.rs
UTF-8
1,407
3.296875
3
[]
no_license
use crate::ray::Ray; use crate::vec::{Vec3, Point3, dot}; use crate::material::Material; pub struct HitRecord { pub p: Point3, pub normal: Vec3, pub t: f32, pub front_face: bool, pub mat: Box<dyn Material>, } impl HitRecord { pub fn set_face_normal(&mut self, r: &Ray, outward_normal: &Vec3) { ...
true
72879c5c0576c66ff0b7d32c54a1754111003069
Rust
66Origin/sofa
/src/lib.rs
UTF-8
9,296
2.90625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! # Sofa - CouchDB for Rust //! //! [![Crates.io](https://img.shields.io/crates/v/sofa.svg)](https://crates.io/crates/sofa) //! [![docs.rs](https://docs.rs/sofa/badge.svg)](https://docs.rs/sofa) //! //! ![sofa-logo](https://raw.githubusercontent.com/YellowInnovation/sofa/master/docs/logo-sofa.png "Logo Sofa") //! //!...
true
4c318fbd283b5f1d7194ee293f91d1764e935c02
Rust
Britefury/lspace
/src/lib/lspace/util/event_test.rs
UTF-8
8,591
3.46875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::fmt::Debug; /// Event tester /// /// A helper harness for testing event-driven code. /// You first register expected events by invoking the @ref expect_event method, then you take the action that causes them to be /// emitted. /// Use as follows: /// 1. Create an event tester /// 2. Implement a listener wit...
true
6d578504d35352efab1f47736af673bf94f8213d
Rust
unnsa/rust
/src/test/ui/impl-trait/equality.rs
UTF-8
1,165
2.734375
3
[ "Apache-2.0", "MIT", "BSD-3-Clause", "NCSA", "LicenseRef-scancode-other-permissive", "BSD-2-Clause" ]
permissive
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
true
1dd7202d94dfa5c7c7bd04ea75473e04af751509
Rust
occar421/ProgrammingContest
/yukicoder/level-2_0/src/no198.rs
UTF-8
6,754
2.921875
3
[]
no_license
use std::io; use std::io::{BufRead, Write}; use std::ops::{Rem, Div, Mul}; use std::cmp::min; macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; (stdin = $s:expr, $($r:tt)*) => { let s = { let mut s...
true
b1ceb6069e6160c7185612b089a6d3791d07f88b
Rust
giodamelio/little_boxes
/vendor/winnow/benches/number.rs
UTF-8
1,823
2.546875
3
[ "MIT" ]
permissive
#[macro_use] extern crate criterion; use criterion::Criterion; use winnow::ascii::float; use winnow::binary::be_u64; use winnow::error::ErrMode; use winnow::error::ErrorKind; use winnow::error::InputError; use winnow::error::ParserError; use winnow::prelude::*; use winnow::stream::ParseSlice; type Stream<'i> = &'i [...
true