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
82af437b1150a9b865085afe46cba0caa24cea10
Rust
joaodelgado/rustyboy
/src/cpu/test/load.rs
UTF-8
16,315
2.8125
3
[]
no_license
#![cfg(test)] use super::*; fn _test_ld_addr_r8<G, F>(r1: G, r2: F, value: u8, addr: u16, opcode: u8) where F: Fn(&mut Cpu, u8), G: Fn(&mut Cpu, u16), { let cpu = &mut Cpu::new(); cpu.mem[0] = opcode; r2(cpu, value); r1(cpu, addr); cpu.tick().unwrap(); assert_eq!(cpu.mem[addr as usize]...
true
a3959f6fa696919eb59030c5e698df8041616c64
Rust
tustvold/rust-playground
/lib/stream/src/limiter.rs
UTF-8
5,678
2.671875
3
[]
no_license
use std::cmp::min; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::pin::Pin; use std::task::{Context, Poll}; use std::time::{Duration, Instant}; use futures::future::{Fuse, FusedFuture}; use futures::{ready, Future, FutureExt}; use pin_project::pin_project; use tokio::stream::Stream; use...
true
b0d692c0e5baabbe077302559275a77e541daa40
Rust
optifat/algorithms_and_data_structures
/src/data_structures/stack.rs
UTF-8
901
4
4
[ "Apache-2.0" ]
permissive
use std::fmt; pub struct Stack<T> { capacity: usize, size: usize, data: Vec<T>, } impl<T: fmt::Debug> Stack<T>{ pub fn new(capacity: usize) -> Stack<T>{ let data: Vec<T> = Vec::with_capacity(capacity); Stack{capacity, size:(0), data} } pub fn add(&mut self, data: T){ i...
true
5f27066bcc583e889893733eb8a908f5aa0b97ec
Rust
Palkovsky/gameboy-emu
/src/mem/mmu.rs
UTF-8
9,321
2.890625
3
[]
no_license
use super::*; /* * MMU struct is responsible for handling address space of CPU. */ pub struct MMU<T: BankController> { /* bootrap contains 256 of boot code. it gets executed first */ pub bootstrap: Vec<Byte>, /* mapper represents the cartdrige and implements its own bank-switching method */ ...
true
49f9f4c44dcd889cf1cc05caab58792512f426c0
Rust
garyttierney/secsp
/packages/libsecsp-parser/src/grammar/error_recovery.rs
UTF-8
1,074
2.828125
3
[ "MIT" ]
permissive
use crate::parser::Parser; use crate::syntax::SyntaxKind; pub(crate) fn recover_from_item(p: &mut Parser) { let mut brace_depth = 0; let m = p.mark(); loop { match p.current() { SyntaxKind::TOK_OPEN_BRACE => { p.bump(); brace_depth += 1; } ...
true
00f1e1b7abadaceebbdc26d26191ba1ea3fbe37b
Rust
bebrws/gol-nvg
/src/main.rs
UTF-8
9,093
3
3
[]
no_license
use nvg::{Align, Color, Context}; use std::time::Instant; const SQUARE_SIZE: u32 = 50; #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Cell { Dead = 0, Alive = 1, } pub struct Universe { width: u32, height: u32, cells: Vec<Cell>, dirty: bool, } impl Universe { fn new(...
true
ab4ce843568c775843475c64fdb562c793d5ff55
Rust
ymgyt/netspeed
/src/util.rs
UTF-8
706
3.484375
3
[]
no_license
use std::time::Duration; pub fn to_bps(bytes: u64, duration: Duration) -> f64 { let bits = bytes * 8; bits as f64 / duration.as_secs_f64() } pub fn format_bps(mut bbs: f64) -> String { let units = ["bps", "Kbps", "Mbps", "Gbps", "Tbps"]; let mut idx = 0; while bbs > 1024f64 && idx < units.len() { ...
true
3d041bdde2cca767f228a42cafc0f248b7f8697f
Rust
jwarwick/aoc_2018
/day24/src/main.rs
UTF-8
10,683
2.78125
3
[ "MIT" ]
permissive
extern crate util; use std::collections::HashSet; use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; fn main() { let armies = build_armies(); let [imm1, infc1] = remaining_units(&armies, 0); println!("Part 1 Result: {}", imm1 + infc1); let result2 = boost(&armie...
true
e90a4fdc71ad2139eabdec9d36c54955e71e0ae8
Rust
duzhanyuan/tower
/tower-util/src/layer/stack.rs
UTF-8
665
3.1875
3
[ "MIT" ]
permissive
use tower_layer::Layer; /// Two middlewares chained together. /// /// This type is produced by `Layer::chain`. #[derive(Clone, Debug)] pub struct Stack<Inner, Outer> { inner: Inner, outer: Outer, } impl<Inner, Outer> Stack<Inner, Outer> { /// Create a new `Stack`. pub fn new(inner: Inner, outer: Outer...
true
059fc1d5121927408b9052474843ca1a718b95cd
Rust
wezm/rust-ip2location
/src/error.rs
UTF-8
1,414
3.015625
3
[ "MIT" ]
permissive
use std::{fmt, io}; #[derive(PartialEq)] pub enum Error { GenericError(String), IoError(String), RecordNotFound(String), InvalidIP(String), InvalidState(String), } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::IoError(err.to_string()) } } impl From<&st...
true
35b31b5835f512c2530785c9f7d4233a94a9bce1
Rust
graphql-rust/graphql-parser
/src/schema/error.rs
UTF-8
563
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
use combine::easy::Errors; use thiserror::Error; use crate::tokenizer::Token; use crate::position::Pos; pub type InternalError<'a> = Errors<Token<'a>, Token<'a>, Pos>; /// Error parsing schema /// /// This structure is opaque for forward compatibility. We are exploring a /// way to improve both error message and AP...
true
f2f083cc70ceb3310113e29592b2d1ae6af9fcf3
Rust
furuhama/rust_sandbox
/src/my_module/read.rs
UTF-8
391
2.703125
3
[]
no_license
use std::io; use std::io::prelude::*; use std::fs::File; #[allow(unused_must_use)] pub fn read() { read_chain(); } fn read_chain() -> io::Result<()> { let c1 = File::open("chain1.txt")?; let c2 = File::open("chain2.txt")?; let mut chain = c1.chain(c2); let mut buffer = String::new(); chain.r...
true
babaa670c6ba01a0996a447f4c0dc2ce430357e4
Rust
NicholasSterling/AsciiStripChart
/src/StripChart.rs
UTF-8
5,990
3.265625
3
[ "MIT" ]
permissive
//use num_traits::{Num,Float}; use num_traits::{Float,Int}; /// Maps values to raw column numbers (which can be out of bounds). pub trait Columnizer<Value> { fn get_raw_col(self: &Self, at: Value) -> isize; } pub struct StripChart<Value, Mark> { columnizer: Columnizer<Value>, } pub struct RoundingColumnizer<...
true
e74107421f8bb684278edc1436993036bf4e7880
Rust
kohbis/leetcode
/algorithms/0718.maximum-length-of-repeated-subarray/solution.rs
UTF-8
527
2.578125
3
[]
no_license
impl Solution { pub fn find_length(nums1: Vec<i32>, nums2: Vec<i32>) -> i32 { let n = nums1.len(); let m = nums2.len(); let mut dp = vec![vec![0; m + 1]; n + 1]; let mut max = 0; for i in 1..=n { for j in 1..=m { if nums1[i - 1] == nums2[j - 1] { ...
true
932015b6da422e329940c7b939306cb9aed9e31c
Rust
jrobsonchase/rlox
/src/lib/instance.rs
UTF-8
1,464
3.03125
3
[]
no_license
use std::{ borrow::Borrow, cell::RefCell, collections::HashMap, fmt, hash::Hash, rc::Rc, }; use crate::*; #[derive(Debug, Clone)] pub struct LoxInstance { inner: InstanceHandle, } impl PartialEq<LoxInstance> for LoxInstance { fn eq(&self, right: &LoxInstance) -> bool { Rc::ptr...
true
5a0cb6f4df9c0be00d6193c71325ccc2ac21b03f
Rust
sagebind/isahc
/src/util/io.rs
UTF-8
2,123
2.875
3
[ "MIT", "CC-BY-4.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Very tiny module containing helpers for `AsyncRead` and `AsyncWrite`. use futures_io::{AsyncRead, AsyncWrite}; use futures_lite::{ future::{poll_fn, yield_now}, pin, }; use std::{ io::{ErrorKind, Result}, pin::Pin, task::{Context, Poll}, }; pub(crate) async fn read_async<R>(reader: &mut R, buf...
true
adb79551bda030a3164765efe2ae83f679ff49b5
Rust
andelf/rust-apue
/examples/fileflags.rs
UTF-8
1,392
2.53125
3
[]
no_license
// List 3-4 #![feature(convert)] extern crate apue; extern crate libc; // cargo run --example fileflags 2 2>>temp.foo use std::env; use std::ffi::CString; use apue::fcntl::*; use libc::{ atoi, c_int, F_GETFL, O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_NONBLOCK, O_SYNC, // O_FSYNC...
true
6a7d9b06936b5de7fd366fd9b1323c2d987f9298
Rust
jhmcstanton/elba-website
/src/user/model.rs
UTF-8
2,003
2.6875
3
[]
no_license
use chrono::NaiveDateTime; use actix::prelude::*; use diesel::{self, prelude::*}; use failure::Error; use crate::database::{Connection, Database}; use crate::schema::users; #[allow(dead_code)] #[derive(Queryable)] pub struct User { pub id: i32, pub email: Option<String>, pub gh_id: i32, pub gh_name: ...
true
be20a39e792a701437c7d8eb8068d4c81979982e
Rust
xenzh/learn-rust
/if-let/src/main.rs
UTF-8
970
3.921875
4
[ "MIT" ]
permissive
fn main() { let func = |out: i32| { println!("Out: {}", out); }; let func2 = || { println!("Got none"); }; let opt: Option<i32> = Some(42); // if we want to call function on unwrapped Option value and do nothing if it's None // 1. use pattern-matching as usual match opt { Some(x) => { func(x); }, ...
true
b695564e1eecf404fdcd259fdebecc6bebd0103b
Rust
joshmarlow/behold-rs
/src/lib.rs
UTF-8
5,432
3.90625
4
[ "MIT" ]
permissive
//! # Behold //! `behold` is a simple library that allows contextual debugging. #[macro_use] extern crate lazy_static; use std::collections::BTreeMap; use std::sync::{Arc, Mutex}; /// The core data structure - stores shared global context and instance specific configuration #[derive(Clone)] pub struct Behold { //...
true
1278e196d12c80e9a7b13bf48d6acc6c4d289c69
Rust
Evian-Zhang/Wispha-old
/src/wispha/common.rs
UTF-8
1,314
2.546875
3
[ "MIT" ]
permissive
use std::rc::{Rc, Weak}; use std::cell::RefCell; use std::collections::HashMap; use std::path::PathBuf; use crate::wispha::core::*; use crate::strings::*; #[derive(Clone)] pub struct WisphaEntry { pub properties: WisphaEntryProperties, pub sup_entry: RefCell<Weak<RefCell<WisphaEntry>>>, // for the root node,...
true
1e092f07ef43f28a2aa34bedb95eed63a3cdfe19
Rust
Observer42/advent-of-code-2017
/src/day22.rs
UTF-8
4,350
3.5625
4
[ "MIT" ]
permissive
use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::io::Result; pub fn solve() -> Result<()> { let mut file = File::open("input/22.txt")?; let mut raw_input = String::new(); file.read_to_string(&mut raw_input)?; let input = parse_input(&raw_input); println!("day 22 first:...
true
fa25bfc234fe84b5e59a8bb315dbdc5462fbec5c
Rust
ps1dr3x/ars-proxy
/src/utils.rs
UTF-8
2,290
2.96875
3
[ "Apache-2.0" ]
permissive
use std::{ env, time::{ SystemTime, UNIX_EPOCH } }; #[derive(Debug, Clone)] pub struct Conf { pub local_port: u16, pub remote_url: String, pub remote_port: u16, pub https_crt: Option<String>, pub https_crt_pass_file: Option<String>, pub to_https: bool, } pub fn get_...
true
9e918b842a43be6378efa7466bfe81effba4c618
Rust
internally-combusted/render-matic
/src/texture.rs
UTF-8
14,229
2.828125
3
[]
no_license
// texture.rs // Creation and handling of images and textures. // (c) 2019, Ryan McGowan <ryan@internally-combusted.net> //! Loading and management of textures. use gfx_backend_metal as backend; use nalgebra_glm as glm; use gfx_hal::{ command::{BufferImageCopy, CommandBuffer, OneShot}, format::{Aspects, Form...
true
8915493d36a7ace26042b666c742570ff665afe5
Rust
swidoff/codewars-rust
/boolfuck/src/main.rs
UTF-8
5,625
3.46875
3
[]
no_license
use itertools::Itertools; #[derive(Debug)] struct Bits { ptr: usize, bytes: Vec<u8>, } impl Bits { fn new() -> Bits { Bits { ptr: 0, bytes: Vec::new() } } fn from(v: Vec<u8>) -> Bits { Bits { ptr: 0, bytes: v } } fn get(&self) -> u8 { let index = self.ptr / 8; let bit: u8 = (self....
true
ebd013d089dead8d2d85fd9afe56e1adaa32fabb
Rust
bevyengine/bevy
/examples/2d/texture_atlas.rs
UTF-8
3,254
3.046875
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! In this example we generate a new texture atlas (sprite sheet) from a folder containing //! individual sprites. use bevy::{asset::LoadState, prelude::*}; fn main() { App::new() .init_resource::<RpgSpriteHandles>() .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blu...
true
618183b7932eef42b5baaaec9ffbd62351153e00
Rust
ojnline/radiothing
/src/app_settings.rs
UTF-8
7,759
3.046875
3
[]
no_license
use std::path::PathBuf; use crate::{decoder::Decoder, settings::Settings}; #[derive(Debug)] pub struct AppSettings { pub auto_device: bool, pub device_filter: String, pub device: String, pub auto_update: bool, pub frequency: f64, pub samplerate: f64, pub gain: f64, pub automatic_gain:...
true
2a582f4ddfcccf9d426e0d9f38952378e9f7a637
Rust
Xion/ezomyte
/src/util/api.rs
UTF-8
2,663
3.59375
4
[ "MIT" ]
permissive
//! Module implementing some API helpers. use std::borrow::Borrow; use std::fmt::Debug; use std::ops::Deref; /// Wrapper around entries that come from the API in batches. /// /// Besides `Deref`ing to the entry type (`T`), the wrapper exposes batch tokens /// (e.g. `change_id` from public stash API) for resuming an ...
true
fdece7209eb73e5b0f3bd0011594b267da765b93
Rust
mozilla/sccache
/src/lru_disk_cache/mod.rs
UTF-8
19,648
2.859375
3
[ "Apache-2.0" ]
permissive
pub mod lru_cache; use fs::File; use fs_err as fs; use std::borrow::Borrow; use std::boxed::Box; use std::collections::hash_map::RandomState; use std::error::Error as StdError; use std::ffi::{OsStr, OsString}; use std::fmt; use std::hash::BuildHasher; use std::io; use std::io::prelude::*; use std::path::{Path, PathBuf...
true
ad77b8715e08362128748c4582c6d312ccf22a33
Rust
JoshOrndorff/advent-of-code-2019
/day07/src/main.rs
UTF-8
2,041
3.4375
3
[]
no_license
use intcode::Intcode; use std::collections::{HashSet, VecDeque}; use std::fs; fn main() { let s = fs::read_to_string("input.txt").unwrap(); // Find all possible orderings let remaining: HashSet<u8> = vec![0, 1, 2, 3, 4].iter().map(|x| *x as u8).collect(); let mut orderings = Vec::new(); get_all_or...
true
0e5b487b0f10c7d6e5d200c54e2715f2c88773b0
Rust
jetbrains-academy/rustlings-course
/Common Collections/Vectors/Create a Vector on Your Own/src/lib.rs
UTF-8
172
2.546875
3
[ "MIT" ]
permissive
pub fn create_array() -> [i32; 4] { let a = [10, 20, 30, 40]; // a plain array a } pub fn create_vector() -> Vec<i32> { let v = vec![10, 20, 30, 40]; v }
true
1157c41297c2bb85dc976679fdcd3a0b1780de22
Rust
RSSchermer/ARWA
/arwa/src/window/bar_state.rs
UTF-8
1,357
2.640625
3
[ "MIT" ]
permissive
pub trait BarState { fn visible(&self) -> bool; fn set_visible(&self, visible: bool); } macro_rules! impl_bar_state { ($tpe:ident) => { impl $tpe { pub(crate) fn new(inner: web_sys::BarProp) -> Self { $tpe { inner } } } impl BarState for $tp...
true
908b9c1a7c13c86e6695ce745b11967208df5917
Rust
openstax/adaptarr-server
/crates/i18n/src/template.rs
UTF-8
3,132
2.828125
3
[]
no_license
use fluent_bundle::types::FluentValue; use log::warn; use serde::Serialize; use std::{borrow::Cow, cell::Cell, collections::HashMap}; use tera::{Tera, Value, compile_templates}; use crate::Locale; pub use tera::Error as RenderError; thread_local!(static LOCALE: Cell<Option<&'static Locale>> = Cell::new(None)); pub ...
true
576d9f3183c3d441f0605db6d6a4785ec6de3cc6
Rust
lanocci/algorithm-and-data-struscture-in-rust
/data_structure/maximum_heap/src/main.rs
UTF-8
570
2.65625
3
[]
no_license
use std::io::*; use util::{Scanner, Joinable}; use complete_binary_tree::CompleteBinaryTree; fn main() { std::thread::Builder::new() .stack_size(1048576) .spawn(solve) .unwrap() .join() .unwrap(); } fn solve() { let cin = stdin(); let cin = cin.lock(); let mut s...
true
c5c93d81d8b7fb09335c0a4cb410bb21e68e453e
Rust
geoengine-bot/geoengine
/datatypes/src/primitives/feature_data.rs
UTF-8
31,238
2.796875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::error; use crate::primitives::PrimitivesError; use crate::util::Result; use arrow::bitmap::Bitmap; use gdal::vector::OGRFieldType; use num_traits::AsPrimitive; use serde::{Deserialize, Serialize}; use serde_json::Value; use snafu::ensure; use std::convert::TryFrom; use std::str; use std::{marker::PhantomData...
true
52a60a123cd99a85bc2b3eb856bd074614a25992
Rust
fabura/icu4x
/components/datetime/src/fields/mod.rs
UTF-8
2,484
2.796875
3
[ "Apache-2.0", "ICU", "MIT", "LicenseRef-scancode-unicode" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). #[macro_use] mod macros; mod length; pub(crate) mod symbols; mod ule; use displaydoc::Display; pub use length::{Fiel...
true
ac7fd5a7d4180782674069c99351b5b3ea123fc6
Rust
alexandervanrenen/adventofcode2020rust
/day10/src/main.rs
UTF-8
2,640
3.234375
3
[]
no_license
use std::io::{self, BufRead}; #[allow(dead_code)] fn task1() { let stdin = io::stdin(); let mut numbers: Vec<usize> = Vec::new(); for strange_line in stdin.lock().lines() { let number: usize = strange_line.unwrap().parse().unwrap(); numbers.push(number); } numbers.sort(); let ...
true
86071b0af247bfdbc80d23ccf145c64d43bfbe91
Rust
VenmoTools/OperatingSystem
/uefis/src/elf/segment.rs
UTF-8
5,480
2.84375
3
[ "Apache-2.0" ]
permissive
use core::fmt; use crate::elf::{Elf32, Elf64, Error, GenElf, GenElfHeader}; use crate::elf::elf_type::{ElfKind, MAGIC_BITES}; use crate::elf::traits::{GenProgramHeader, GenSectionHeader}; //////////////////// //// Segments //////////////////// pub struct ProgramHeader<'a, E: GenElf> { elf: &'a E, pub ph: &'a ...
true
c3fe4c1aca4b1eb8c3edce789c27cce2b38b75b2
Rust
jhand2/rust-arpspoofr
/src/main.rs
UTF-8
1,825
2.53125
3
[ "MIT" ]
permissive
extern crate clap; extern crate ctrlc; pub mod arp; pub mod net; use arp::*; use std::net::{IpAddr, Ipv4Addr}; use std::sync::Arc; use clap::{App, Arg}; struct Arguments { interface: String, source_ip: Ipv4Addr, target_ip: Ipv4Addr, } fn parse_args() -> Arguments { let args = App::new("gthttp") ...
true
3facc98ed9fde46bb3fd15a53a24f7ab2df9ff44
Rust
dmitryikh/rust-ml-algo
/src/tree/impurity.rs
UTF-8
10,335
2.734375
3
[]
no_license
pub fn entropy(p_vec: &[f64]) -> f64 { debug_assert!(p_vec.iter().any(|&p| p >= 0.0 && p <= 1.0)); p_vec.iter().fold(0.0, |s, &p| s - if p != 0.0 { p * p.log2() } else { 0.0 }) } pub fn entropy_bin(p: f64) -> f64 { entropy(&[p, 1.0 - p]) } pub fn gini(p_vec: &[f64]) -> f64 { debug_assert!(p_vec.iter(...
true
147774a77d21a2cdc8386ee7bba11c8560a6b863
Rust
leftiness/hex_math
/src/traits/distance/base.rs
UTF-8
789
3.796875
4
[ "MIT" ]
permissive
use std::borrow::Borrow; use structs::Point; /// Trait wrapping base distance implementation pub trait Base: Borrow<Point> { /// Calculate the manhattan distance between two points ignoring height /// /// Distance is rounded to the nearest integer. fn base_distance<U: Borrow<Point>>(&self, other: &U) -> i32; ...
true
f5e00f48b5e4c75889371c535a37835182c2264a
Rust
katharostech/parry
/src/query/closest_points/closest_points.rs
UTF-8
1,362
3.328125
3
[ "Apache-2.0" ]
permissive
use crate::math::{Isometry, Point, Real}; use std::mem; /// Closest points information. #[derive(Debug, PartialEq, Clone, Copy)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum ClosestPoints { /// The two objects are intersecting. Intersecting, /// The two objects are non-intersect...
true
7b7ba17a5c7fbc8fe172a8869d61f2ce787bb12e
Rust
PistonDevelopers/skeletal_animation
/src/blend_tree.rs
UTF-8
20,846
2.546875
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::rc::Rc; use rustc_serialize::{Decodable, Decoder}; use animation::{AnimationClip, ClipInstance}; use skeleton::{Skeleton, JointIndex}; use transform::Transform; use math::*; /// Identifier for an AnimationClip within a BlendTreeNodeDef pub type ClipId = String; /// Identifie...
true
2920bc96ee18b13ccbe434b9118b853a2c131d09
Rust
Hyperion101010/multithreaded-web-rust
/src/main.rs
UTF-8
785
3.0625
3
[]
no_license
use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::fs; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); for stream in listener.incoming() { let stream = stream.unwrap(); println!("Connected"); handle_con(stream); } } fn ...
true
c07eaddf554fc6c5dfdfcdb6d24b81f71bb9966c
Rust
zhangbozhi01/leetcode-2
/.test_repo/src/lib.rs
UTF-8
2,299
3.171875
3
[]
no_license
/* * @lc app=leetcode.cn id=687 lang=rust * * [687] 最长同值路径 */ #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { ...
true
9074617cf331940039140a872c2d6aa9f95e7b52
Rust
vinicius-of/Rust
/check-list/src/main.rs
UTF-8
245
3.125
3
[]
no_license
use std::io; fn main() { let mut list = Vec::new(): list.push("Test 1"); list.push("Test 2"); //It is a test while(true){ let mut input = io::stdin().read_line() .expect("Problem from input"); } }
true
c3e384ce6990b6cc06a1a3865c6da079ac2bceac
Rust
taochunyu/editor_lib
/editor/src/state/text_selection.rs
UTF-8
2,398
2.90625
3
[]
no_license
use std::rc::Rc; use std::any::Any; use crate::{Doc, Position}; use crate::node::path::Path; use crate::state::selection::Selection; use crate::transform::mapping::Mapping; use crate::transform::mappable::{Mappable, AssociatedSide}; use crate::node::slice::Slice; use crate::transform::Transform; const TEXT_SELECTION_N...
true
50f6842ce28dec94231d492c2014960b2b5b0dc9
Rust
Troland/viz
/viz-core/src/types/cookies.rs
UTF-8
4,117
2.75
3
[ "Apache-2.0", "MIT" ]
permissive
use std::{ fmt, sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}, }; use viz_utils::{futures::future::BoxFuture, thiserror::Error as ThisError, tracing}; use crate::{ http, types::{Cookie, CookieJar, Key}, Context, Extract, Response, Result, }; /// Cookies Error #[derive(ThisError, Debug, P...
true
63dcb35364575b7054f6ee9bb553b4665acf630a
Rust
autocatalytic/witter
/backend/src/responses.rs
UTF-8
1,237
2.65625
3
[]
no_license
use serde::Serialize; use shared::responses::ApiResponse; use tide::http::Error; use tide::http::StatusCode; use tide::Body; use tide::Response; pub trait ApiResponseExt { fn to_response_with_status(self, status: StatusCode) -> Result<Response, Error>; #[allow(dead_code)] fn to_response(self) -> Result<Re...
true
16a424f5a2b571a1c9f13ce893da9a92f51e5486
Rust
laucia/euler-project
/src/bin/2.rs
UTF-8
785
3.609375
4
[]
no_license
// [Problem 2]: (https://projecteuler.net/problem=2) // - - - - - - - - - - - - - - - - - - - - - - - - - // Each new term in the Fibonacci sequence is generated by adding the previous // two terms. By starting with 1 and 2, the first 10 terms will be: // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... // By considering the ...
true
3bb920821a38695b4d16fd64b5d8ad8ef8296e7a
Rust
Gigoteur/UnicornConsole
/unicorn-console/src/input/gamepad_bindings.rs
UTF-8
1,080
2.796875
3
[ "MIT" ]
permissive
use unicorn::input::ButtonCode; use gilrs::Button; use hashbrown::HashMap; #[derive(Debug)] pub(crate) struct GamepadBindings { pub buttons: HashMap<Button, ButtonCode>, } impl Default for GamepadBindings { fn default() -> Self { let buttons = [ (Button::DPadUp, ButtonCode::Up), ...
true
fb6c7f466f0d34b3fd96c91acbd8e3c1df3c3a43
Rust
amethyst/specs
/src/error.rs
UTF-8
2,986
3.53125
4
[ "MIT", "Apache-2.0" ]
permissive
//! Specs errors //! //! There are specific types for errors (e.g. `WrongGeneration`) //! and additionally one `Error` type that can represent them all. //! Each error in this module has an `Into<Error>` implementation. use std::{ convert::Infallible, error::Error as StdError, fmt::{Debug, Display, Formatt...
true
6ffda2f95b0858fd410ac0a1381e5b8f685e2d58
Rust
ciusji/ferris
/src/example/conversion/try_from_into.rs
UTF-8
782
3.328125
3
[ "Apache-2.0" ]
permissive
// Copyright 2021 Ferris Project Authors. License user Apache License. // Similar to From and Into, TryFrom and TryInto are generic traits from converting between types. use std::convert::TryFrom; use std::convert::TryInto; #[derive(Debug, PartialEq)] struct EvenNumber(i32); impl TryFrom<i32> for EvenNumber { t...
true
3bcbad16b9a039ae27c268b924bfcc4e2732f8e3
Rust
ptal/bonsai
/src/middle/recursive_call.rs
UTF-8
6,118
2.546875
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 Pierre Talbot (IRCAM) // 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
81eb28f526e18e10b5024730c2f60900787ee290
Rust
xneomac/oikos
/src/rust/oikos_web/src/components/tabs.rs
UTF-8
2,558
2.796875
3
[]
no_license
use crate::root::AppRoute; use yew::prelude::*; use yew_router::{ agent::RouteRequest, prelude::{Route, RouteAgentDispatcher}, RouterState, }; pub struct Tabs<STATE: RouterState = ()> { link: ComponentLink<Self>, router: RouteAgentDispatcher<STATE>, } pub enum Message { ChangeRoute(AppRoute), ...
true
145b220dba9567a69c0fa2cb5d45becc470c9766
Rust
jamesmarva/Head-First-Rust
/ch20/s1/s1d1/src/main.rs
UTF-8
528
3.125
3
[]
no_license
fn main() { let mut v1 = Vec::<i32>::new(); println!("Start: length {} capacity {}", v1.len(), v1.capacity()); for i in 1..10 { v1.push(i); println!("pushed {}; length: {}; capacity: {}", i, v1.len(), v1.capacity()); } let mut v2 = Vec::<i32>::with_capacity(1); println!("Start...
true
e38a7165e0df514e9493de53bb7cfa556468b10a
Rust
jolocom/keriox
/src/prefix/attached_signature.rs
UTF-8
4,424
2.765625
3
[ "Apache-2.0" ]
permissive
use super::{Prefix, SelfSigningPrefix}; use crate::{ derivation::{ attached_signature_code::AttachedSignatureCode, self_signing::SelfSigning, DerivationCode, }, error::Error, }; use base64::decode_config; use core::str::FromStr; use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[deriv...
true
f62bbd6591e124c2b4621bc5a72614f2c5e500ed
Rust
chadrc/simple-expression-language
/sel_common/src/sel_types/list.rs
UTF-8
590
3
3
[]
no_license
use crate::SELValue; #[derive(Clone, Serialize, Deserialize, Debug)] pub struct List { values: Vec<SELValue>, } impl List { pub fn new() -> Self { return List { values: vec![] }; } pub fn get_values(&self) -> &Vec<SELValue> { return &self.values; } pub fn push(&mut self, valu...
true
2475503c83ffc17cc38db470f788927f56cf0fe7
Rust
scottwillmoore/chip16
/src_old/instruction.rs
UTF-8
2,647
3.21875
3
[ "MIT" ]
permissive
use failure::Error; use self::Condition::*; use self::Operation::*; #[derive(Debug, PartialEq)] pub enum Operation { NOP, JMPI, LDIR, } impl Operation { pub fn new(data: u8) -> Result<Operation, Error> { match data { 0x00 => Ok(NOP), 0x01 => Ok(JMPI), 0x02 ...
true
bfa32b2c08ae8ef051e8d398739007915fb43b79
Rust
SKTT1Ryze/resume-rs
/src/education.rs
UTF-8
1,192
3.59375
4
[ "MIT" ]
permissive
//! Education Experience Implementation of `ResumeElement` Trait //! Maily include undergraduate, master, doctor, etc. //! //! Example: //! ```Rust //! ``` //! use crate::{Inner, IntoInner, ResumeElement}; #[derive(Default)] pub struct Education { inners: Vec<Box<dyn EduInner>>, } impl Education { pub ...
true
be907488755274101fc5c74240704e3f1acda4b7
Rust
galihaulia/basic_rust_lang
/src/types.rs
UTF-8
1,222
3.375
3
[]
no_license
/* Primitive Types-- Integers: u8, i8, u16, i16, u32, i32, u64, i64, u128, i128 (number of bits they take in memory) Floats: f32, f64 Boolean (bool) Characters (char) Tuples Arrays */ pub fn types_res(){ //Default is "i32" let x = 1; let x1 = 2; //Default is "f64" let y = 2.5; //add explicit t...
true
28abb25076c5c12b75c68eb39974a83abe60b960
Rust
samrat/miri
/tests/run-pass/float.rs
UTF-8
12,229
3.171875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![feature(track_caller)] use std::fmt::Debug; // Helper function to avoid promotion so that this tests "run-time" casts, not CTFE. // Doesn't make a big difference when running this in Miri, but it means we can compare this // with the LLVM backend by running `rustc -Zmir-opt-level=0 -Zsaturating-float-casts`. #[trac...
true
8b0449042ab350666713f5f78b70ad4981092d87
Rust
droundy/clapme
/tests/primitive.rs
UTF-8
2,521
2.8125
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright 2018 David Roundy <roundyd@physics.oregonstate.edu> // // 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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or ...
true
2c219fc34b580e3f50c2a922e12a3dc1fdbbcb54
Rust
Keats/jsonwebtoken
/examples/auth0.rs
UTF-8
1,496
2.5625
3
[ "MIT" ]
permissive
/// Example for the backend to backend implementation use std::collections::HashMap; use jsonwebtoken::jwk::AlgorithmParameters; use jsonwebtoken::{decode, decode_header, jwk, DecodingKey, Validation}; const TOKEN: &str = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjFaNTdkX2k3VEU2S1RZNTdwS3pEeSJ9.eyJpc3MiOiJodHRwcz...
true
073524182f120793b4df3b0f0061582359cf84b7
Rust
joelimgu/youtube-tui
/src/model/tui/widgets/clear_area.rs
UTF-8
427
2.546875
3
[]
no_license
use crossterm::{terminal, QueueableCommand}; use std::io::stdout; use tui::buffer::Buffer; use tui::layout::Rect; use tui::widgets::Widget; pub struct Clear; impl Widget for Clear { fn render(self, _area: Rect, _buf: &mut Buffer) { clear(); } } pub fn clear() { let mut stdout = stdout(); stdou...
true
e6cad87b79c5a87606ce1cd79bd51153fb10e81d
Rust
jetbrains-academy/rustlings-course
/Standard Library Types/Smart Pointers/Switch the Lamp/src/switcher.rs
UTF-8
330
2.796875
3
[ "MIT" ]
permissive
use crate::lamp::Lamp; pub struct Switcher<'a> { lamp: &'a Lamp } impl<'a> Switcher<'a> { pub fn new(lamp: &'a Lamp) -> Self { Switcher { lamp } } pub fn switch(&self) { if self.lamp.is_on() { self.lamp.switch_off() } else { self.lamp.switch_on() ...
true
983416cfd7e14a77d4e36338d67b900a44f9ac2f
Rust
strega-nil/nushell
/crates/nu-command/src/filters/take/take_.rs
UTF-8
2,996
2.796875
3
[ "MIT" ]
permissive
use std::convert::TryInto; use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, }; #[derive(Clone)] pub struct Take; impl Command for Take { fn ...
true
214ff317b8f5c65cebc55e27a9793c3d2a270d8b
Rust
JennToo/j2gbc
/j2gbc/src/timer.rs
UTF-8
2,952
2.875
3
[]
no_license
use std::cmp::min; use std::num::Wrapping; use super::cpu::{Interrupt, InterruptSet, CLOCK_RATE}; use super::mem::*; use crate::error::ExecutionError; const DIV_INCREMENT_CYCLE_COUNT: u64 = CLOCK_RATE / 16_779; const TIMA_INCREMENT_CYCLE_COUNT: [u64; 4] = [ CLOCK_RATE / 4_096, CLOCK_RATE / 262_144, CLOCK_...
true
103083212b3b551022ed3a7ec056e62c538bf054
Rust
dyule/optra
/src/lib.rs
UTF-8
3,995
3.125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! An engine for keeping remote siles synchronized. //! //! The engine is based on the Admissabilty Based Sequence Transformation algorithm (doi: [10.1109/TPDS.2010.64](http://dx.doi.org.ezproxy.library.dal.ca/10.1109/TPDS.2010.64)) //! The idea is that each site that wants to have a file synchronized will have an ins...
true
b52b5bffe4a5b6c7c4af4e7f5a5846312911ab5b
Rust
benhirsch24/ripelines
/src/base/mod.rs
UTF-8
8,618
3.0625
3
[]
no_license
use std::collections::HashMap; use std::collections::LinkedList; use std::rc::{Rc}; use std::cell::{RefCell}; pub struct Buffer { pub size: usize, pub data: Vec<u8> } impl Buffer { pub fn new(data: Vec<u8>, size: usize) -> Buffer { Buffer { data: data, size: size } ...
true
6f056655ae6b04d30cfdc9f934f52404295c2a00
Rust
Xudong-Huang/may
/may_queue/src/spsc.rs
UTF-8
13,123
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
use crossbeam_utils::CachePadded; use smallvec::SmallVec; use crate::atomic::{AtomicPtr, AtomicUsize}; use std::cell::UnsafeCell; use std::cmp; use std::marker::PhantomData; use std::mem::MaybeUninit; use std::ptr; use std::sync::atomic::Ordering; // size for block_node pub const BLOCK_SIZE: usize = 1 << BLOCK_SHIFT...
true
b83352439e675f6725b7c1b8438fdcc0ccaf716c
Rust
weblfe/ext-php-rs
/src/types/object.rs
UTF-8
10,586
3.03125
3
[ "Apache-2.0", "MIT" ]
permissive
//! Represents an object in PHP. Allows for overriding the internal object used //! by classes, allowing users to store Rust data inside a PHP object. use std::{convert::TryInto, fmt::Debug, ops::DerefMut}; use crate::{ boxed::{ZBox, ZBoxable}, class::RegisteredClass, convert::{FromZendObject, FromZval, F...
true
996a0110697bbdc70a2e75537110f6e2e12e1d59
Rust
FedeVerstraeten/tdl-mozart-fiuba
/tp-rust/examples/Eze/prestamo/prestamo-02.rs
UTF-8
1,112
3.625
4
[]
no_license
//las referencias a secas son inmutables, como los enlaces a variables //Esto quiere decir que en el fooLindo de antes //no puedo cambiar los vectores fn main(){ let mut v1 = vec![1,2,3]; //fooMut(&mut v1);//le paso una ref mutable, entonces puedo //cambiar v1 let mut v2 = &mut v1; fooMutMut(&mut v2); //...
true
21b9a29f58e389f84cd2257d1c67ac55f8bc49cf
Rust
fabura/icu4x
/components/decimal/src/sign_selector.rs
UTF-8
1,327
3.046875
3
[ "Apache-2.0", "ICU", "MIT", "LicenseRef-scancode-unicode" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). //! Algorithms to determine how to render the sign. use crate::options::SignDisplay; use fixed_decimal::Signum; pub...
true
d607343a2f81f7bae377af011d8b641d1671b35d
Rust
torch-rs/sorters
/src/files_sorter.rs
UTF-8
2,777
2.921875
3
[]
no_license
extern crate regex; extern crate search_candidate; use self::regex::Regex; use self::search_candidate::SearchCandidate; use self::search_candidate::Key; use Sort; use std::cmp::Ordering; use std::path::MAIN_SEPARATOR; pub struct FilesSorter; impl Sort for FilesSorter { fn sort(candidates: &Vec<SearchCandidate>)...
true
d05301212baaba74a79d8dededa83cbfe05663f2
Rust
luolong/gearley
/tests/grammars/precedenced_arith.rs
UTF-8
1,892
2.890625
3
[ "Apache-2.0", "MIT" ]
permissive
use cfg::Symbol; use cfg::earley::Grammar; pub fn grammar() -> Grammar { let mut bnf = Grammar::new(); let (sum, product, factor, number, plus, minus, mul, div, lparen, rparen) = bnf.sym(); bnf.rule(sum).rhs([sum, plus, product]) .rhs([sum, minus, product]) .rhs([product])...
true
fd730e2cea2fb6c523612c4d709832a313f3c733
Rust
jackcmay/solana
/install/src/config.rs
UTF-8
3,975
2.640625
3
[ "Apache-2.0" ]
permissive
use { crate::update_manifest::UpdateManifest, serde::{Deserialize, Serialize}, solana_sdk::pubkey::Pubkey, std::{ fs::{create_dir_all, File}, io::{self, Write}, path::{Path, PathBuf}, }, }; #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] pub enum ExplicitRelease { ...
true
28974c3daa9c0775d122c123d2011c581ce170aa
Rust
nikomatsakis/rust-runtime-benchmarks
/runtime-benchmarks/raytrace/src/main.rs
UTF-8
4,407
2.84375
3
[ "LicenseRef-scancode-public-domain" ]
permissive
#![feature(test)] // Dependencies extern crate rand; // generate random numbers extern crate lodepng; // output PNG image files extern crate test; // Ray-tracer modules mod vec; // basic 3D vector math mod model; // geometry of objects in the scene mod materials; // reflective properties of surface...
true
09c4b3ffb1e4e43c5e03314080f491f24b7fdaac
Rust
mickdekkers/mqtt-async-client-rs
/src/error.rs
UTF-8
1,806
3.21875
3
[ "MIT" ]
permissive
use std::{ convert::From, fmt::{Debug, Display, Formatter, self}, }; /// Fallible result values returned by the library. pub type Result<T> = std::result::Result<T, Error>; /// Errors returned by the library. #[derive(Debug)] pub enum Error { /// The client is disconnected. Disconnected, /// An e...
true
ae451765fffe8b9d2ac06b0b6cdd53f88e7dba27
Rust
sybila/biodivine-lib-std
/src/collections/sets/mod.rs
UTF-8
5,899
3.9375
4
[ "MIT" ]
permissive
//! A struct that implements `Set` is assumed to hold a collection of values, however the //! collection itself does not have to be explicit. Items of a `Set` can be even uncountable. //! //! Because Rust currently does not have a `Set` trait (and even if it had, its use case would //! probably differ from ours), we in...
true
41bbbebad28c87bc6fbf404a8b04038db869d81c
Rust
JulianKnodt/cirrust
/src/bounding_box.rs
UTF-8
5,789
3.015625
3
[]
no_license
use crate::point::{Point}; #[derive(PartialEq, Debug, Clone, Copy)] pub struct BoundingBox { ll: Point, rr: Point, } impl BoundingBox { pub fn new(ll: Point, rr:Point) -> Self { assert_eq!(ll.len(), rr.len()); assert!(ll.iter().enumerate().all(|(i,d)| d <= rr[i])); BoundingBox{ll, rr} } pub fn jus...
true
be2fbfeeeb866553c0065ed995b269d1f6cf15fd
Rust
shreve/cryptopals
/src/cracking.rs
UTF-8
4,019
3.125
3
[]
no_license
use crate::Bytes; use crate::{encrypt, transform}; use std::cmp::Ordering; use std::collections::BinaryHeap; pub fn single_byte_cipher(input: &Bytes) -> (usize, u8, Bytes) { let dict: Bytes = (0x00..0xFF).collect(); let mut high_score = 0; let mut key: u8 = 0; let mut best: Bytes = vec![0; input.len()...
true
f716b334ed202824aeb8427f64325e70e9d411b8
Rust
brandon-chow/crustydb
/src/common/src/storage_trait.rs
UTF-8
3,627
3.25
3
[]
no_license
use crate::ids::Permissions; use crate::ids::*; use crate::CrustyError; // TODO: What does ContainerId add as a type? If nothing, then make it u16 and make it easier for clients of // TODO: storage managers to use them /// The trait for a storage manager in crustyDB. /// A StorageManager should impl Drop also so a st...
true
dc2511a38ec9f4c460403e47ebfcf079e1fa0e5a
Rust
GGalizzi/raycaster
/src/texture.rs
UTF-8
2,765
3.171875
3
[]
no_license
use png; use std::fs::File; pub struct Texture { data: Vec<u8>, width: u32, height: u32, } impl Texture { pub fn new(path: &str) -> Texture { let decoder = png::Decoder::new(File::open(path).unwrap()); let (info, mut reader) = decoder.read_info().unwrap(); let mut buf = vec![0;...
true
61026bd4e9dd7d8248e044fa7df2013deb0aa674
Rust
iridium-browser/iridium-browser
/third_party/beto-core/src/nearby/connections/ukey2/ukey2/src/state_machine.rs
UTF-8
10,225
2.703125
3
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2023 Google LLC // // 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 in w...
true
77990a65524a8265131862e4d15342162d451d28
Rust
LinusU/rust-emoji-commit-types
/src/lib.rs
UTF-8
7,190
3.484375
3
[]
no_license
use std::fmt; use std::mem; /// A semver bump level #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum BumpLevel { Major, Minor, Patch, None, } impl BumpLevel { /// Return the name of this bump level pub fn name(&self) -> &'static str { match *self { BumpLevel::Major => ...
true
a50c235e403e45f34f2ba529b9767935d2b44b90
Rust
phial3/kafka-delta-ingest
/src/metrics.rs
UTF-8
11,820
2.609375
3
[ "Apache-2.0" ]
permissive
use dipstick::*; use log::error; use std::convert::TryInto; use std::time::Instant; /// The environment variable used to specify how many metrics should be written to the metrics queue before flushing to statsd. const METRICS_INPUT_QUEUE_SIZE_VAR_NAME: &str = "KDI_METRICS_INPUT_QUEUE_SIZE"; /// The environment variabl...
true
4870cadd8e0241a1d9370b41a50dff2e8016d33f
Rust
satanson/rust_etudes
/n031_Next_Permutation/src/main.rs
UTF-8
682
3.265625
3
[]
no_license
struct Solution{} impl Solution { pub fn next_permutation(nums: &mut Vec<i32>) { let n = nums.len(); if n < 2 { return; } //seek for minimum ascend pair; let mut ii = 0; let mut jj = 0; for i in 0..n { for j in i+1..n{ if nums[i] < nums[j] { ii = i; ...
true
6138d27cd2a48a471c0dc09100669d5e19381f11
Rust
Texlo-Dev/rust-beginners
/variables/src/main.rs
UTF-8
2,386
4.21875
4
[ "MIT" ]
permissive
fn main() { // Let - by default declares an immutable (not changeable) variable which can be shadowed. let x: i32 = 1111; // With type annotation/ let x = 1111; // Type will be inferred. // Adding a 'mut' keyword befor the variable declaration will allow it to be changed. let mut x = "...
true
ad21b8ec6aa915d0a4d3a668f1dfef3ce9d32324
Rust
Killavus/rust-playground
/panic_fun/src/main.rs
UTF-8
221
2.78125
3
[]
no_license
use std::io; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input).unwrap(); let input: u32 = input.trim().parse().unwrap(); let foo: u32 = input - 100; println!("{}", foo); }
true
ed5f73a5e7325656d70f83a0049ed3c06d94e2c8
Rust
selatotal/rust-playground
/12.collections/strings/src/main.rs
UTF-8
209
3.296875
3
[ "MIT" ]
permissive
fn main() { let data = "initial contents"; let mut s = data.to_string(); s = "initial contents".to_string(); s = String::from("foo"); s.push_str("bar"); println!("Hello, {}!", s); }
true
76b9d7df93ace67f11ff98bf7c539310c492fbb0
Rust
marceloboeira/trpl
/chapters/chapter-6/example3.rs
UTF-8
375
3.21875
3
[ "MIT" ]
permissive
enum IpAddr { V4(String), V6(String), } fn print_ip(ip: IpAddr) { match ip { IpAddr::V4(addr) => println!("IPV4: {}", addr), IpAddr::V6(addr) => println!("IPV6: {}", addr) } } fn main() { let home = IpAddr::V4(String::from("127.0.0.1")); let loopback = IpAddr::V6(String::from("...
true
2e94d1bd8f59aef3f3dcd063c83c37626e4ab498
Rust
Nereuxofficial/rust_move_gen
/src/integrity.rs
UTF-8
13,072
2.921875
3
[ "MIT" ]
permissive
use castle::*; use castling_rights::*; use piece::*; use position::Position; use side::*; use square::*; /* CHECKS: - bitpositions and array representation must be consistent - piece counts must be legal (ie pawns + rooks <= 10) - castling rights only valid if king/rook haven't moved - pawns cannot...
true
296581743f9377b38eaae0a314411c6d10d7a419
Rust
dseres/rcs-parser
/src/parsers/delta.rs
UTF-8
2,214
2.90625
3
[ "MIT" ]
permissive
#![allow(dead_code)] use crate::{parsers::*, *}; use nom::{ character::complete::multispace0, combinator::opt, error::{context, VerboseError}, sequence::preceded, IResult, }; /// Parsing delta part of comma-v files. /// /// Grammar of delta is the following: /// > delta ::= num /// > "date"...
true
2feb47d42c81e4c1725c97319e53099614b02506
Rust
feroxide/feroxide-gui
/src/printer.rs
UTF-8
3,425
3.09375
3
[ "MIT" ]
permissive
use piston_window::*; use piston_window::types::*; use piston_window::character::CharacterCache; /// Prints text to the screen pub struct Printer { pub font_size: FontSize, pub glyphs: Glyphs, pub ctx: Context, line_nr: u32, left_padding: Scalar, } impl Printer { /// Create a new Printer ...
true
f2031d8b445b674cec3612479f40c768b44d195d
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-41880.rs
UTF-8
679
3.625
4
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn iterate<T, F>(initial: T, f: F) -> Iterate<T, F> { Iterate { state: initial, f: f, } } pub struct Iterate<T, F> { state: T, f: F } impl<T: Clone, F> Iterator for Iterate<T, F> where F: Fn(&T) -> T { type Item = T; #[inline] fn next(&mut self) -> Option<Self::Item> { ...
true
add8aff03d193f07a762a3dbf78f0f3a56934c25
Rust
Telixia/leetcode-3
/Medium/0057-Insert Interval/Solution.rs
UTF-8
772
2.5625
3
[]
no_license
impl Solution { pub fn insert(intervals: Vec<Vec<i32>>, mut new_interval: Vec<i32>) -> Vec<Vec<i32>> { let mut flag = true; let mut ret = vec![]; for interval in intervals { if interval[0] > new_interval[1] { if flag { ret.push(new_interval.cl...
true
cc7b496973388dfd5f07dfcde08a705378d47eac
Rust
fry/n2k
/src/bus.rs
UTF-8
7,002
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use core::{convert::TryFrom, fmt::Debug}; use crate::hal_can::{self, Receiver, Transmitter}; use crate::CanFrame; use crate::{Id, IdError, Message, GLOBAL_ADDRESS}; const CB_TP_BAM: u8 = 0x40; // Control byte indicating TP_BAM const PGN_TP_CM: u32 = 0x00ec00; // 60416 - ISO Transport Protocol, Connection Management ...
true
72f1c7b8b8904a25a121b6c105782977912f9be5
Rust
nkgfirecream/polars
/polars/polars-lazy/src/physical_plan/executors/projection.rs
UTF-8
823
2.609375
3
[ "MIT" ]
permissive
use crate::physical_plan::executors::evaluate_physical_expressions; use crate::physical_plan::state::ExecutionState; use crate::prelude::*; use polars_core::prelude::*; /// Take an input Executor (creates the input DataFrame) /// and a multiple PhysicalExpressions (create the output Series) pub struct ProjectionExec {...
true
3d91b45a9b640a43c993049caa23c6d5b052eb9c
Rust
VinithKrishnan/Prism_Voting_Chains
/src/ledger_manager.rs
UTF-8
12,049
2.765625
3
[ "MIT" ]
permissive
use crate::crypto::hash::{H256, Hashable}; use crate::blockchain::Blockchain; use crate::block::Content; use crate::transaction::SignedTransaction; use crate::utxo::UtxoState; use std::collections::{HashMap, HashSet}; use std::thread; use std::time::{SystemTime, UNIX_EPOCH, Duration}; use std::sync::{Arc, Mutex}; use...
true