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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d651f0ba4a96ba5a7494c5eda92efeb1690d3003 | Rust | ci4ic4/libmacchina | /src/shared/mod.rs | UTF-8 | 8,690 | 2.6875 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
#![allow(unused_imports)]
use crate::traits::ReadoutError;
use crate::extra;
use std::ffi::CStr;
use std::io::Error;
use std::path::Path;
use std::process::{Command, Stdio};
use std::{env, fs};
#[cfg(any(target_os = "linux", target_os = "macos"))]
use sysctl::SysctlError;
#[cfg(any(target_os = ... | true |
34e8e0c6c41b71a47bf74652fb8e4d8f4b600321 | Rust | winding-lines/weaver | /weaver/src/cli/parse.rs | UTF-8 | 5,015 | 2.734375 | 3 | [] | no_license | use super::APP_NAME;
use clap::{App, Arg, ArgGroup, ArgMatches, SubCommand};
use lib_goo::config::{OutputKind, ServerConfig};
const VERSION: &str = env!("CARGO_PKG_VERSION");
const DESCRIPTION: &str = env!["CARGO_PKG_DESCRIPTION"];
/// Commands returned by the parser for execution in the main loop.
#[derive(Debug)]
p... | true |
ca49cd5c0a78c5926387626a18d71d70683a262f | Rust | ArtemKyslicyn/mull | /lab/rust/example.rs | UTF-8 | 396 | 3.328125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
pub fn sum(a: i32, b: i32) -> i32 {
return a + b;
}
pub fn just_print() {
println!("I am just_print() function. I just say hello!");
}
#[test]
fn rusttest_foo_sum1() {
assert!(sum(3, 4) == 7);
}
#[test]
fn rusttest_foo_sum2() {
assert!(sum(4, 5) == 9);
}
#[test]
fn rusttest_foo_sum3() {
assert!(sum(5, 6)... | true |
ce40f7f4181f4f397298b0604aeae2bf1ffc3858 | Rust | weirane/aoc-2020 | /src/bin/05.rs | UTF-8 | 498 | 2.890625 | 3 | [] | no_license | fn decode_seat(seat: &str) -> u32 {
seat.chars().fold(0, |acc, c| {
acc * 2 + if c == 'B' || c == 'R' { 1 } else { 0 }
})
}
fn main() {
let seats: Vec<_> = aoc_2020::stdin_lines()
.map(|s| s.map(|s| decode_seat(&s)))
.collect::<Result<_, _>>()
.unwrap();
let (min, max) ... | true |
771fa6f4634eb472469bc03d62e6d1abfb8e2088 | Rust | sugyan/leetcode | /others/july-leetcoding-challenge-2021/week-4/3824/lib.rs | UTF-8 | 1,807 | 3.421875 | 3 | [] | no_license | use std::cell::RefCell;
use std::rc::Rc;
use utils::TreeNode;
pub struct Solution;
impl Solution {
pub fn prune_tree(root: Option<Rc<RefCell<TreeNode>>>) -> Option<Rc<RefCell<TreeNode>>> {
if let Some(r) = root {
let val = r.borrow().val;
let left = Self::prune_tree(r.borrow().left... | true |
3c2e511dfc53d9c6e5ee8bc7e8e57ae32c296365 | Rust | mwarzynski/uw_dust | /examples/good/requirementsfor17_20points.rs | UTF-8 | 507 | 3.375 | 3 | [] | no_license | struct Point {
x: int,
y: int
}
fn random() -> int {
return 7;
}
fn main() -> {
i: int = 0;
{
i: int = 2;
}
print("8. OK // i=", i);
print("9. OK // 'Runtime error: Division by zero'");
print("10. OK // random=", random());
p: Point;
p.x = 5;
p.y = 10;
pr... | true |
395f133a0973cd3ba032c2f461beb988a71e5d14 | Rust | chiral-data/rust-canonical-numbering | /src/core/reduce/case_cyclic.rs | UTF-8 | 16,538 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 Chiral Ltd.
// Licensed under the Apache-2.0 license (https://opensource.org/licenses/Apache-2.0)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! Case cyclic
use crate::core;
use super::mapping_ops;
fn filter_cyclic_orbits<T: core::graph::Vertex>(
... | true |
3b7f80aefd4b4d5bebfb76e327b0bc6485d6ebd6 | Rust | fits/try_samples | /rust/sample/pattern_match_sample.rs | UTF-8 | 803 | 3.375 | 3 | [] | no_license |
fn main() {
print_num(0);
print_num(3);
print_num(5);
print_num(7);
print_num2(0);
print_num2(3);
print_num2(5);
print_num2(7);
println!("{}", update_num(0));
println!("{}", update_num(3));
println!("{}", update_num(5));
println!("{}", update_num(7));
println!("{}", update_num2(3));
println!("{}", upd... | true |
7c2ae3664fb62ec2e071a6ea47aee21bf299526a | Rust | chenkai06ofc/restaurant-api | /src/item.rs | UTF-8 | 7,338 | 2.578125 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
use redis::{Commands, Connection};
use std::collections::{HashMap, HashSet};
use rand::Rng;
use tokio::sync::Mutex;
use std::sync::Arc;
use mysql::Pool;
use mysql::prelude::Queryable;
pub const MIN_TABLE_NO: u32 = 1;
pub const MAX_TABLE_NO: u32 = 100;
const COOK_QUEUE_LEN: u32 = 2... | true |
883da3a6ad65226539052e6d2bdfa9a2ca40e459 | Rust | Daenecompass/cognitive-services-speech-sdk-rs | /examples/recognizer/helpers.rs | UTF-8 | 4,932 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use cognitive_services_speech_sdk_rs::audio::{
AudioConfig, AudioStreamFormat, PullAudioInputStream, PushAudioInputStream,
};
use cognitive_services_speech_sdk_rs::speech::{SpeechConfig, SpeechRecognizer};
use log::*;
use std::env;
use std::io::Read;
/// convenience function to setup environment variables
/// subs... | true |
a93b2595b61bce607f4d7617ca328f835d40da7f | Rust | unleashed/const_fixedp | /src/lib.rs | UTF-8 | 39,399 | 3.359375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) 2021 - Alejandro Martinez Ruiz <alex@flawedcode.org>
//
// const_fixedp - A crate to handle const unsigned fixed point values.
//
// So far this only includes addition and subtraction, with no (direct)
// conversions from f32/f64, and the internal type used is set to `u64`.
//
// There is optional supp... | true |
4cc5052ec5dd1a3842eac57b091f5045233c36fb | Rust | yin939/Exercism | /rust/affine-cipher/src/lib.rs | UTF-8 | 2,244 | 3.671875 | 4 | [] | no_license | /// While the problem description indicates a return status of 1 should be returned on errors,
/// it is much more common to return a `Result`, so we provide an error type for the result here.
#[derive(Debug, Eq, PartialEq)]
pub enum AffineCipherError {
NotCoprime(i32),
}
/// Encodes the plaintext using the affine... | true |
4be366e0b0881536cafec5178aab8bf2ecb37c57 | Rust | NLincoln/tree-data | /data/src/page/btree.rs | UTF-8 | 6,967 | 2.9375 | 3 | [] | no_license | use super::{InternalPage, Key, LeafPage, Page, PageOffset};
use crate::{Database, Disk};
use std::io;
pub struct BTree {
root: PageOffset,
}
impl BTree {
pub fn offset(&self) -> PageOffset {
self.root
}
pub fn from_offset(offset: PageOffset) -> BTree {
Self { root: offset }
}
... | true |
c589a7f2fc26be09dc52a98495c9aab970e2ebd1 | Rust | TimeToogo/wezterm | /window/src/os/wayland/keyboard.rs | UTF-8 | 4,497 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::input::*;
use crate::os::wayland::connection::WaylandConnection;
use anyhow::anyhow;
use smithay_client_toolkit as toolkit;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use toolkit::reexports::calloop::LoopHandle;
use toolkit::seat::keyboard::{
map_keyboard_repeat, Event as KbEvent, KeySta... | true |
4b638c3343c75fb04d27b9a52f540870f1c58571 | Rust | ottingbob/rust-dojo | /5-typez/5-4-alias.rs | UTF-8 | 300 | 3.09375 | 3 | [] | no_license |
// `nsec` is a new name for `u64`
type NSec = u64;
type Inch = u64;
#[allow(non_camel_case_types)]
type u64_t = u64;
fn main() {
let nanoseconds: NSec = 5 as u64_t;
let inches: Inch = 2 as u64_t;
println!("{} ns + {} in = {} unit?",
nanoseconds,
inches,
nanoseconds + inches);
} | true |
66cfa06fcec866a84acaed2bfdc5e3c68b1b52e8 | Rust | sjakthol/rust-sshprobe | /src/socket.rs | UTF-8 | 1,214 | 3.328125 | 3 | [
"MIT"
] | permissive | use std;
use std::io::{Error, ErrorKind};
use std::net::{SocketAddr, ToSocketAddrs};
static SSH_DEFAULT_PORT: u16 = 22;
/// Resolves the peer address to connect to. If the hostname or IP provided by
/// the user does not contain a port, the default SSH port, 22, is used.
pub fn get_peer_addr(addr: &str) -> std::io::R... | true |
30abdec0dbc83cfabb7df049eaba223c17bd7433 | Rust | aaronhktan/stm32-exploration | /07-rust/stm32l0x1/stm32l0x1_pac/src/flash.rs | UTF-8 | 6,570 | 2.515625 | 3 | [
"MIT"
] | permissive | #[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Access control register"]
pub acr: ACR,
#[doc = "0x04 - Program/erase control register"]
pub pecr: PECR,
#[doc = "0x08 - Power down key register"]
pub pdkeyr: PDKEYR,
#[doc = "0x0c - Program/erase key register"]... | true |
f17b90167991591a9620f0e617fed0f715ec9cd4 | Rust | aaron-human/fluffy-tribble | /src/collider.rs | UTF-8 | 2,409 | 3.140625 | 3 | [] | no_license | use core::fmt::Debug;
use downcast_rs::{Downcast, impl_downcast};
use crate::types::{Vec3, Mat3, EntityHandle};
/// A way to quickly determine collider type.
#[derive(PartialEq, Eq)]
pub enum ColliderType {
/// For the [crate::NullCollider].
NULL,
/// For the [crate::SphereCollider].
SPHERE,
/// For the [crate:... | true |
41e333208977dce4fe69006ca349158ddf86f98b | Rust | KodrAus/yaml | /tests/structs/in.rs | UTF-8 | 6,041 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use serde;
#[derive(Serialize, Deserialize, Default)]
pub struct Data1 {
pub i32: i32,
pub i64: i64,
pub u32: u32,
pub u64: u64,
pub f32: f32,
pub f64: f64,
pub string: String,
pub i32a: Vec<i32>,
pub hash: HashMap<String, Data1>
}
#[derive(Serialize,... | true |
20df027f12f8a43fb8d0778e8ee67d212c9ab9aa | Rust | udoprog/OxidizeBot | /tools/builder/src/wix_builder.rs | UTF-8 | 2,723 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::env::consts::EXE_EXTENSION;
use std::env::{self, consts};
use std::path::{Path, PathBuf};
use anyhow::{bail, ensure, Context, Result};
use crate::command::Command;
use crate::Release;
pub(crate) struct WixBuilder {
candle_bin: PathBuf,
light_bin: PathBuf,
wixobj_path: PathBuf,
installer_path... | true |
3cb46e7d5b08350f53e761e6572ef85e0f6e9208 | Rust | BITICPC/WaveJudge | /driver/src/forkserver/core.rs | UTF-8 | 4,902 | 2.765625 | 3 | [] | no_license | //! This module implements the core logic of the fork server.
//!
use std::time::Duration;
use sandbox::{MemorySize, SystemCall};
use judge::{
CompilationTaskDescriptor,
CompilationResult,
JudgeTaskDescriptor,
JudgeResult,
};
use judge::engine::{
JudgeEngine,
JudgeEngineConfig,
};
use super:... | true |
3ebfe982cc50b32fb85848e71f12b522cc2f70e3 | Rust | pnnl/lamellar-runtime | /src/array/iterator/one_sided_iterator/skip.rs | UTF-8 | 1,321 | 2.796875 | 3 | [
"BSD-3-Clause"
] | permissive | use crate::array::iterator::one_sided_iterator::*;
// use crate::array::LamellarArrayRequest;
// use crate::memregion::OneSidedMemoryRegion;
// use async_trait::async_trait;
use pin_project::pin_project;
#[pin_project]
pub struct Skip<I> {
#[pin]
iter: I,
}
impl<I> Skip<I>
where
I: OneSidedIterator + Sen... | true |
d6781aea6033ca3a5fa3e1514943e13a23012eb2 | Rust | tirust/msp432e4 | /src/emac0/lpitimerctl.rs | UTF-8 | 3,538 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive | #[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::LPITIMERCTL {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(... | true |
ac4bc085a42cd33edd68a535e00a29f33818d637 | Rust | michaeljones/elm-parser | /src/ast/expression/character.rs | UTF-8 | 1,485 | 3.234375 | 3 | [] | no_license | use ast::expression::core::Expression;
use std;
use nom::anychar;
use nom::types::CompleteStr;
named!(character_content<CompleteStr, char>,
alt!(
// Look for hex codes starting with \\x
map_res!(
do_parse!(
tag!("\\x") >>
code: take!(2) >>
(u8::from_str_radix(code.... | true |
36d0a33b8c326d9d400554c60d25c4cfe42679da | Rust | vincentisambart/chocolatier | /fossil/generate.rs | UTF-8 | 738 | 2.578125 | 3 | [] | no_license | use chocolatier::xcode::Target;
use chocolatier::{ast, generator};
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "generate",
about = "Generate all bindings from specified file."
)]
struct Opt {
/// Input file
#[structopt(parse(from_os_str))]
input... | true |
2c76535b35d5b4f68ea826903e8902ac032eaebe | Rust | davidkern/rust-lib | /src/prelude/src/string.rs | UTF-8 | 8,890 | 3.71875 | 4 | [
"MIT"
] | permissive | //! This module defines several useful string variants, including copy-on-write and immutable
//! implementations.
use std::borrow::Cow;
use crate::impls;
use crate::clone::*;
use std::ops::Deref;
use std::rc::Rc;
use derive_more::*;
use serde::Deserialize;
use serde::Serialize;
// =================
// === StringO... | true |
e0b6b59714b92d4f293848fe6b10752442254beb | Rust | abhro/rust-book | /rectangle_structs/src/method_user.rs | UTF-8 | 454 | 3.21875 | 3 | [] | no_license | mod lib;
use lib::Rectangle;
fn main() {
let rect1 = Rectangle { width: 30, length: 50 };
println!("rect1 is {:?}", rect1);
println!("The area of the rectangle is {} square pixels.", rect1.area());
let rect2 = Rectangle { width: 10, length: 40 };
let rect3 = Rectangle { width: 60, length: 45 };
... | true |
4e89123f27078f6eac4f5f73ec4b04396b2416a5 | Rust | MuhannadAlrusayni/savory | /style/src/position.rs | UTF-8 | 4,969 | 2.921875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{calc::Calc, unit::*, values as val, St, StyleValues, UpdateStyleValues};
use derive_rich::Rich;
use savory::prelude::DeclarativeConfig;
/// ```
/// use savory_style::{Style, unit::px};
///
/// Style::default()
/// .and_position(|conf| {
/// conf.absolute().top(px(28)).left(px(40))
/// });
/... | true |
5da97849a0a781e75dcbb9a7f7fe6cbac671b230 | Rust | shunte88/ssd1327 | /examples/raspberry_pi.rs | UTF-8 | 1,252 | 2.640625 | 3 | [] | no_license | use {
display_interface_spi::SPIInterface,
embedded_graphics::{
fonts::{Font24x32, Text},
pixelcolor::Gray4,
prelude::*,
text_style,
},
linux_embedded_hal::Delay,
rppal::{
gpio::Gpio,
spi::{Bus, Mode, SlaveSelect, Spi},
},
ssd1327,
};
fn main(... | true |
297b2288d881411b54d7fb5ad4ed230a2572d68b | Rust | annacrombie/edr_test | /src/script/interpreter.rs | UTF-8 | 1,496 | 3.03125 | 3 | [] | no_license | use std::collections::HashMap;
use crate::error::Error;
use crate::script::{AstNode, AstNodeType};
type Scope = HashMap<String, String>;
pub fn interp_expr(expr: &AstNode, scope: &Scope) -> Result<String, Error> {
match expr.t {
AstNodeType::Call(func, ref args_node) => {
let mut args: Vec<St... | true |
08a4ffdc9e93cf9792406d2b99ae317bcbff1d92 | Rust | GarrettSocling/rdedup | /lib/src/tests.rs | UTF-8 | 13,500 | 2.65625 | 3 | [] | no_license | mod lib {
pub use super::super::*;
}
use hex::ToHex;
use iterators::StoredChunks;
use rand::{self, Rng};
use settings;
use sha2::{Sha256, Digest};
use std::{io, cmp};
use std::collections::HashSet;
use std::fs;
use std::fs::OpenOptions;
use std::io::{Result, Write};
use std::path;
use std::path::PathBuf;
const ... | true |
14c0a35daecb3763717d58da0636cbe4c62ec5fe | Rust | ggriffiniii/api_updater | /gen/google_vault_v1/src/lib.rs | UTF-8 | 406,108 | 2.6875 | 3 | [] | no_license | pub mod schemas {
#[derive(
Debug,
Clone,
PartialEq,
Hash,
PartialOrd,
Ord,
Eq,
Default,
:: serde :: Deserialize,
:: serde :: Serialize,
)]
pub struct AccountInfo {
#[doc = "A set of accounts to search."]
#[serde... | true |
7d5193036b0782d378099b4d82233f5f9dd6f0b7 | Rust | oxidecomputer/typify | /cargo-typify/tests/outputs/builder.rs | UTF-8 | 5,704 | 3 | 3 | [
"Apache-2.0"
] | permissive | #![allow(clippy::redundant_closure_call)]
#![allow(clippy::needless_lifetimes)]
#![allow(clippy::match_single_binding)]
#![allow(clippy::clone_on_copy)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Fruit(pub serde_json::Map<String, serde_json::Value>);
impl std::ops:... | true |
205dd1a97e73f55a466c5b0925ce2c645b59c35f | Rust | EvanJP/icu4x | /components/fs-data-provider/src/export/mod.rs | UTF-8 | 2,508 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unicode",
"ICU",
"Apache-2.0"
] | permissive | //! The `export` feature enables you to pull all data from some other data provider and persist it
//! on the filesystem to be read by an FsDataProvider at runtime.
//!
//! Also see the binary "icu4x-cldr-export".
//!
//! # Examples
//!
//! ```
//! use icu_data_provider::prelude::*;
//! use icu_data_provider::Invariant... | true |
ee9f45b5a3d0f25571c7efd35bb6d9823f50702f | Rust | cuviper/hyper-staticfile | /src/util/open_with_metadata.rs | UTF-8 | 742 | 2.671875 | 3 | [
"MIT"
] | permissive | use std::fs::{Metadata, OpenOptions as StdOpenOptions};
use std::io::Error as IoError;
use std::path::Path;
use tokio::fs::{File, OpenOptions};
#[cfg(windows)]
use std::os::windows::fs::OpenOptionsExt;
#[cfg(windows)]
use winapi::um::winbase::FILE_FLAG_BACKUP_SEMANTICS;
/// Open a file and get metadata.
pub async fn ... | true |
5d2ff4128eefc7ecbe5b9ddece19623e956eff12 | Rust | thea0032/the_game | /src/ui/object.rs | UTF-8 | 8,526 | 2.78125 | 3 | [] | no_license | use info::information;
use location::get_location;
use quickie::quickie;
use resources::get_resource_filtered;
use select::generic_select;
use crate::{
component::*,
resources::*,
systems::*,
ui::{component::*, system::*, *},
};
use crate::{
instr::Directions,
systems::{object_id::ObjectID, sys... | true |
5c8ecb4a57151c039b9333c8885fc8bb4e81ba41 | Rust | eugene-bulkin/crates.io | /src/crate_owner_invitation.rs | UTF-8 | 2,580 | 2.578125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use conduit::{Request, Response};
use diesel::prelude::*;
use time::Timespec;
use db::RequestTransaction;
use schema::{crate_owner_invitations, users, crates};
use user::RequestUser;
use util::errors::CargoResult;
use util::RequestUtils;
/// The model representing a row in the `crate_owner_invitations` database table... | true |
e61c73f10f903416e299660a9d10856bf6a74e56 | Rust | project-oak/oak | /oak_restricted_kernel/src/args.rs | UTF-8 | 3,508 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | //
// Copyright 2022 The Project Oak Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law o... | true |
baf2398ca4c90a3b636a82100d44ba45e73d483e | Rust | Tenjin0/beginning-rust | /chap10/src/bin/lifetime.rs | UTF-8 | 305 | 2.75 | 3 | [] | no_license | use chap10::lifetime;
fn main() {
let str1 = String::from("abcd");
{
let str2 = "uvwxyz";
let mut result = lifetime::longest(str1.as_str(), str2);
println!("{}", result);
result = lifetime::longest2(str1.as_str(), str2);
println!("{}", result);
}
}
| true |
f2def572d960af55785a054beb1c702a1372ded8 | Rust | RustWorks/openshift-openapi-codegen | /src/v4_2/api/authorization/v1/group_restriction.rs | UTF-8 | 3,953 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | // Generated from definition com.github.openshift.api.authorization.v1.GroupRestriction
/// GroupRestriction matches a group either by a string match on the group name or a label selector applied to group labels.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct GroupRestriction {
/// Groups is a list of grou... | true |
dd818633cfedfc4a39ca934ad78ed5ba1d8d8141 | Rust | KevinKoshka/hello-rust | /src/main.rs | UTF-8 | 2,956 | 3.734375 | 4 | [] | no_license | // 0. Correr "$ rustc main.rs" crea un binario ejecutable.
// 0.1 Cargo es el sistema de buildeo de Rust y package manager.
// 0.2 "$ cargo build" buildea el código y "$ cargo run" ejecuta el binario
// generado en target/debug.
// 0.3 "$ cargo check" chequea que el código compile sin errores sin producir
// un... | true |
d22dac0f93dee3eb46ab56ff8dca9c53d896dc0c | Rust | sria91-rlox/RustLox-1 | /src/object.rs | UTF-8 | 1,671 | 3.484375 | 3 | [] | no_license | use std::{collections::HashSet, fmt::Display, hash::Hash, rc::Rc};
pub trait LoxObject {
// Common information for garbage collection
}
#[derive(Clone, PartialEq, Debug)]
pub struct ObjString {
pub string: String,
}
impl LoxObject for ObjString {}
#[derive(Clone, PartialEq, Debug)]
pub enum Object {
// ... | true |
eeab15767abe8ff129184bf6969e79e47a5ed1cf | Rust | nebkor/stellar-sdk | /cli/src/resolution.rs | UTF-8 | 1,763 | 3.734375 | 4 | [
"MIT"
] | permissive | use self::Resolution::{Day, Hour, Min, Sec};
use std::str::FromStr;
/// Represents durations of time for the trade aggregations endpoint.
pub enum Resolution {
Sec(u32),
Min(u32),
Hour(u32),
Day(u32),
}
#[derive(Debug)]
pub enum ParseResolutionError {
InvalidNumber,
InvalidUnit,
}
impl Resolu... | true |
fd655798001e44253d1697866e2eb43f26da2219 | Rust | Otavio-Burato/URI | /rust/ex1006.rs | UTF-8 | 1,869 | 3.5 | 4 | [
"CC0-1.0"
] | permissive | // https://github.com/Otavio-Burato/URI/tree/main/rust/src
// 1006 - Média 2
// Rust (1.48) {beta}
use std::io;
/// # Entrada
/// O arquivo de entrada contém 3 valores com uma casa decimal, de dupla precisão (double).
fn main() {
let mut input_a = String::new();
let mut input_b = String::new();
let mut inp... | true |
ecdaacbd041513b9d3710155f1106a7dfe555184 | Rust | soapwong/rust-renderer | /src/matrix.rs | UTF-8 | 4,535 | 3.328125 | 3 | [] | no_license | use crate::vector::Vector;
use std::ops::Mul;
#[derive(Copy, Clone)]
pub struct Matrix {
m: [f32; 16],
}
impl Matrix {
pub fn new(values: [f32; 16]) -> Self {
Matrix { m: values }
}
pub fn zero() -> Self {
Self { m: [0.0; 16] }
}
pub fn look_at_lh(eye: &Vector, target: &Vecto... | true |
bc451b90f51249d9b0e52769536ee6285b07538e | Rust | google/tock-on-titan | /third_party/clap/src/args/subcommand.rs | UTF-8 | 1,921 | 3.140625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | // Third Party
#[cfg(feature = "yaml")]
use yaml_rust::Yaml;
// Internal
use App;
use ArgMatches;
/// The abstract representation of a command line subcommand.
///
/// This struct describes all the valid options of the subcommand for the program. Subcommands are
/// essentially "sub-[`App`]s" and contain all the same... | true |
ac43654b697b815b9431b11f67f636ad3c05f7ef | Rust | chinanf-boy/gentle-intro | /code/thread6.rs | UTF-8 | 321 | 3.46875 | 3 | [
"MIT"
] | permissive | // thread6.rs
use std::thread;
fn main() {
let one = thread::spawn(move || {
println!("I am one");
});
let two = thread::spawn(move || {
// wait for one to finish...
one.join().unwrap();
// and then we can go
println!("I am two");
});
two.join().unwrap();
}... | true |
1c262d5e5f10af26a50df8aada4edae4de786ec2 | Rust | katrinasm/exlev | /src/spr.rs | UTF-8 | 2,817 | 3.109375 | 3 | [] | no_license | use std::collections::BTreeSet;
use std::cmp;
#[derive(Copy, Clone, Debug)]
pub struct SpritePlacement {
pub id: u16,
pub pos_x: u16,
pub pos_y: u16,
pub xbit: bool,
pub xbytes: [u8; 4],
}
pub type SprSet = BTreeSet<SpritePlacement>;
impl SpritePlacement {
pub fn new(id: u16, pos_x: u16, pos_... | true |
99a7709ddc08ea0372515ac436f6c93d70ab1423 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/plist/src/stream/xml_reader.rs | UTF-8 | 8,440 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use
base64
;
use
std
:
:
{
io
:
:
{
self
Read
}
str
:
:
FromStr
}
;
use
xml_rs
:
:
{
common
:
:
{
is_whitespace_str
Position
}
reader
:
:
{
Error
as
XmlReaderError
ErrorKind
as
XmlReaderErrorKind
EventReader
ParserConfig
XmlEvent
}
}
;
use
crate
:
:
{
error
:
:
{
Error
ErrorKind
FilePosition
}
stream
:
:
{
Event
OwnedE... | true |
d3ec745d87a85784d81858747ba75b411369bddf | Rust | zeroexcuses/makepad | /render/src/quad.rs | UTF-8 | 3,122 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::cx::*;
#[derive(Clone)]
pub struct Quad {
pub shader: Shader,
pub z: f32,
pub color: Color
}
impl Quad {
pub fn new(cx: &mut Cx) -> Self {
Self {
shader: live_shader!(cx, self::shader),
z: 0.0,
color: Color::parse_name("green").unwrap()
... | true |
57c56b379d8638c90385072304f0708ea912add8 | Rust | aphorisme/raio-rs | /src/connectivity/version.rs | UTF-8 | 1,510 | 3.734375 | 4 | [] | no_license | #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Version {
pub min: u8,
pub maj: u8,
}
impl Version {
/// Creates a new `Version` with provided major and minor increment.
pub fn new(maj: u8, min: u8) -> Self {
Version {
maj,
min,
}
}
/// Creates a... | true |
7bb60328c42519a24324ffec2476c6f65ec59419 | Rust | jlgerber/pkmake | /src/targets/install_test.rs | UTF-8 | 17,751 | 2.546875 | 3 | [] | no_license | //
// Unit tests for install.rs
//
use super::*;
use std::env;
use serial_test::serial;
use crate::utils::setup_manifest_dir;
use crate::utils::setup_manifest_dir2;
// This tests that we can construct an appropriate default
#[test]
fn can_construct_default() {
let result = Install::default();
let expected = I... | true |
9927e75715f1994941a0f238fe686bdd8a897576 | Rust | Nashenas88/borrow_visualizer_prototype | /data/scopes_test2.rs | UTF-8 | 267 | 3.09375 | 3 | [] | no_license | struct Foo;
fn max<'a>(x: &'a Foo, y: &'a Foo) -> &'a Foo {
x
}
fn main() {
let a = Foo;
let y: &Foo;
{
let target = Foo;
y = max(&a, &target);
// error: `target` does not live long enough
}
// potentially more code
} | true |
95e07f3137bc6d49cb3338f50fa167a90ac43d1c | Rust | Ruin0x11/sabi | /src/renderer/atlas/mod.rs | UTF-8 | 11,028 | 2.5625 | 3 | [] | no_license | use std::cell::RefCell;
use std::collections::HashMap;
use std::fs::{self, File};
use std::path::Path;
use glium;
use glium::backend::Facade;
use image::{self, DynamicImage, GenericImage, Rgba};
use texture_packer::Rect;
use texture_packer::SkylinePacker;
use texture_packer::{TexturePacker, TexturePackerConfig};
use t... | true |
b8b741718d75e20886c7310e220d9883ba7fa973 | Rust | isgasho/rusmo | /src/file.rs | UTF-8 | 3,240 | 3.03125 | 3 | [
"MIT"
] | permissive | use ansi_term::Colour;
use chrono::Utc; use serde::{Deserialize, Serialize};
use std::fs::{self, File};
use std::io;
use std::io::Write;
use std::os::unix::process::CommandExt;
use std::path::Path;
use std::process::Command;
extern crate dirs;
extern crate serde;
extern crate toml;
const EXPAND: &str = ".md";
#[deri... | true |
310d33d69f1853e8cc26384ceb24a556c660dd2c | Rust | Alpaca-H/rust | /src/test/ui/const-generics/forbid-non-structural_match-types.rs | UTF-8 | 290 | 2.625 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | #![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
#[derive(PartialEq, Eq)]
struct A;
struct B<const X: A>; // ok
struct C;
struct D<const X: C>; //~ ERROR the types of const generic parameters must derive
fn main() {}
| true |
dc32d25d2b9cb57c092f5b9af318a50fbcddc70b | Rust | sanpii/wiki-md | /src/error.rs | UTF-8 | 1,580 | 3.125 | 3 | [] | no_license | #[derive(Debug)]
pub enum Error {
NotFound,
Template(tera::Error),
}
impl From<tera::Error> for Error {
fn from(err: tera::Error) -> Self {
Error::Template(err)
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match... | true |
c1dd128ff0c79abce745f7f4e4ad18f207ca391b | Rust | cakebaker/aoc-2020-rust | /src/bin/04.rs | UTF-8 | 3,870 | 3.046875 | 3 | [] | no_license | use std::collections::HashMap;
use std::env;
use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let file_content =
fs::read_to_string(filename).expect("Something went wrong reading the file!");
let lines = to_passport_lines(file_content);
let ... | true |
00255062a9e02ff31e4d90068abecace69c8ef82 | Rust | simd-lite/value-trait | /src/node/from.rs | UTF-8 | 2,145 | 2.65625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::StaticNode;
/********* atoms **********/
impl From<bool> for StaticNode {
#[inline]
#[must_use]
fn from(b: bool) -> Self {
Self::Bool(b)
}
}
impl From<()> for StaticNode {
#[inline]
#[must_use]
fn from(_b: ()) -> Self {
Self::Null
}
}
/********* i_ ********... | true |
a77d82101d615d5545dade6a2880512e8e78b7c2 | Rust | GoXLR-on-Linux/goxlr-utility | /ipc/src/clients/web/web_client.rs | UTF-8 | 1,804 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | use crate::client::Client;
use crate::{DaemonRequest, DaemonResponse, DaemonStatus, GoXLRCommand, HttpSettings};
use anyhow::bail;
use async_trait::async_trait;
#[derive(Debug)]
pub struct WebClient {
url: String,
status: DaemonStatus,
http_settings: HttpSettings,
}
impl WebClient {
pub fn new(url: St... | true |
1821d1ebeabe792898afc563cbf6cd7731ee9b12 | Rust | OrangeBacon/scheme | /compiler/src/environment.rs | UTF-8 | 5,205 | 2.75 | 3 | [
"MIT"
] | permissive | use std::{collections::HashMap, ops::Range};
use lasso::{Capacity, Rodeo, Spur};
use crate::{
config::{Configuration, ConfigurationCategory, Flag, WarningLevel},
ir::IrBuilder,
memory::Heap,
parser::Parser,
value::Value,
};
#[derive(Debug, Clone)]
pub struct File {
name: String,
content: ... | true |
07501e8ef25fd5c7d706037ea1d3a07bee776516 | Rust | vincentisambart/chocolatier | /chocolatier_objc_parser/src/xcode.rs | UTF-8 | 5,443 | 3.1875 | 3 | [] | no_license | use once_cell::sync::Lazy;
use std::borrow::Cow;
use std::process::Command;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Sdk {
MacOs,
IOs,
IOsSimulator,
TvOs,
TvOsSimulator,
WatchOs,
WatchOsSimulator,
}
impl Sdk {
pub fn sdk_name(self) -> &'static str {
match self {
... | true |
4adaad64cf4ad620dccc85d5fb7664afd39f0251 | Rust | WRansohoff/svd2rust_example_stm32l0x1 | /svd_lib/stm32l0x1/src/rcc/cr.rs | UTF-8 | 20,152 | 2.828125 | 3 | [
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::CR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W)... | true |
029a71a8d8c326328392cce72a28e76aebc92b4b | Rust | pabloguerino/vagga | /src/builder/commands/text.rs | UTF-8 | 816 | 2.53125 | 3 | [
"MIT"
] | permissive | use std::io::Write;
use std::fs::{File, set_permissions, Permissions};
use std::path::{PathBuf, Path};
use std::collections::BTreeMap;
use std::os::unix::fs::PermissionsExt;
use path_util::ToRelative;
use builder::guard::Guard;
use builder::error::StepError;
pub fn write_text_files(files: &BTreeMap<PathBuf, String>,... | true |
a9c7a45cf0827cd672df6cb1a29310174be04753 | Rust | uenoka/rust-practice | /src/bin/enum.rs | UTF-8 | 456 | 3.28125 | 3 | [] | no_license | // define enum
enum IpAddrKind {
v4,
v6,
}
#[derive(Debug)]
enum IpAddr {
v4(String),
v6(String),
}
#[derive(Debug)]
enum IpAddr2 {
v4(u8, u8, u8, u8),
v6(String),
}
fn main() {
// instantiate
let four = IpAddr2::v4(127, 0, 0, 1);
let six = IpAddr::v6(String::from... | true |
557b96604c4b234d0a56f39fc47b258a933f9379 | Rust | maco/unused | /crates/token_search/src/token.rs | UTF-8 | 3,396 | 3.3125 | 3 | [
"MIT"
] | permissive | use itertools::Itertools;
use read_ctags::{CtagItem, Language, ReadCtagsError, Tags, TagsReader};
use serde::Serialize;
use std::collections::HashSet;
use std::path::PathBuf;
/// A token based on a set of `CtagItem`s
#[derive(Clone, Serialize)]
pub struct Token {
/// The token value
pub token: String,
/// ... | true |
8111661372931435e0df762c5a87780e2828ba86 | Rust | lo48576/fbxcel-dom | /src/v7400/data/mesh/layer.rs | UTF-8 | 8,607 | 2.890625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Layers.
use std::convert::{TryFrom, TryInto};
use anyhow::{bail, format_err, Error};
use fbxcel::{low::v7400::AttributeValue, tree::v7400::NodeHandle};
pub(crate) use self::common::LayerContentIndex;
pub use self::{
color::LayerElementColorHandle,
common::{LayerElementHandle, MappingMode, ReferenceInfor... | true |
f4c56d5beda0ad4abea78454fb00b05918194066 | Rust | Slimakanzer/itmo-fourth-year | /computer-graphics/lab2/src/shader.rs | UTF-8 | 3,787 | 2.828125 | 3 | [] | no_license | use std::ffi::CString;
use std::fs;
use std::ptr;
use std::str;
use gl;
use gl::types::*;
use cgmath::prelude::*;
use cgmath::{Matrix, Matrix4, Vector2, Vector3};
pub struct Shader {
pub id: u32,
}
impl Shader {
pub fn new(vertex: &str, fragment: &str) -> Shader {
let mut shader = Shader { id: 0 };
... | true |
a5373a33b9ee90a537ce040abf3a2b959e076d44 | Rust | eulegang/txt-cluster | /src/doc_reader.rs | UTF-8 | 5,016 | 3.546875 | 4 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use std::io::{BufRead, BufReader, Read};
pub enum RecordSeperator {
Null,
Line,
Paragraph,
}
pub struct DocReader<R>
where
R: BufRead,
{
read: R,
buf: Vec<u8>,
irs: RecordSeperator,
}
impl<R> DocReader<R>
where
R: BufRead,
{
pub fn new(read: R, irs: RecordSeperator) -> DocReader<R... | true |
724e4299baa90480b0c9fa9408d82b39ef59a4c1 | Rust | ericoseid/jam_list_hashing_service | /src/data/request_response.rs | UTF-8 | 401 | 2.875 | 3 | [] | no_license | pub struct RequestResponse {
status_code : String,
body : String
}
impl RequestResponse {
pub fn get_status_code(&self) -> &String {
&self.status_code
}
pub fn get_body(&self) -> &String {
&self.body
}
pub fn new(status_code: &str, body: &str) -> RequestResponse {
RequestResponse {
st... | true |
44e0a64412e3da3897a979a4c6676428054319a7 | Rust | glide1/exercism | /rust/sum-of-multiples/src/lib.rs | UTF-8 | 137 | 2.953125 | 3 | [] | no_license | pub fn sum_of_multiples(num: u32, multiples: &[u32]) -> u32 {
(1..num).filter(|&i| multiples.into_iter().any(|x| i % x == 0)).sum()
} | true |
38f3f50d2f6d3d9f085b3aa34067f9800c868cbf | Rust | sambordo1/invaders | /invaders/src/shot.rs | UTF-8 | 1,742 | 3.5 | 4 | [] | no_license | use std::time::Duration;
use rusty_time::timer::Timer;
use crate::frame::{Drawable, Frame};
pub struct Shot {
pub x: usize,
pub y: usize,
pub exploding: bool, // whether its exploding or not
timer: Timer, // timer to keep track of movement
}
impl Shot { // implement shot logic
pub fn new(x: usize,... | true |
634277c870df88eef57f4fa81ed26d2ab43852ca | Rust | itto-ki/atcoder | /ABC/005/A.rs | UTF-8 | 362 | 2.984375 | 3 | [] | no_license | #[allow(unused_must_use)]
fn read_intpair() -> (i32, i32) {
let mut input = String::new();
std::io::stdin().read_line(&mut input);
let v: Vec<i32> = input
.trim()
.split_whitespace()
.map(|x| x.parse().unwrap())
.collect();
(v[0], v[1])
}
fn main() {
let (x, y) = rea... | true |
52eff6a04f50ce1c9f865a45a2fc423cc31c9cfe | Rust | jdwile/advent-of-code | /2022/advent-of-code-2022/src/bin/13.rs | UTF-8 | 4,986 | 3.21875 | 3 | [] | no_license | use std::{
cmp::Ordering,
fmt::{Display, Error, Formatter},
str::FromStr,
};
#[aoc::main(13)]
pub fn main(input: &str) -> (usize, usize) {
solve(input)
}
#[aoc::test(13)]
pub fn test(input: &str) -> (String, String) {
let res = solve(input);
(res.0.to_string(), res.1.to_string())
}
fn solve(i... | true |
beb94e67677a51f2a18a332d0c8e4c90b27a3bfe | Rust | yongkyuns/noon_egui | /src/vehicle/state.rs | UTF-8 | 2,868 | 3.03125 | 3 | [] | no_license | // use crate::geom::{point, Angle, HasOrientation, HasPosition, Point};
use crate::S;
use crate::{pt, Spatial, Visual, WithSpatial, WithVisual};
#[derive(Debug, Clone, Copy)]
pub struct VehicleState {
Vx: S,
Vy: S,
Fxf: S,
Fxr: S,
RWA: S,
dPSI: S,
spatial: Spatial,
// visual: Visual,
}
... | true |
b346d2d6ed1c5bbc45e06cf66a7900ac92b27ec0 | Rust | stpyramids/stpyr | /stpyr/src/def/terrain.rs | UTF-8 | 757 | 2.875 | 3 | [] | no_license | use failure::Error;
use crate::resources::*;
#[derive(Deserialize, Clone)]
pub struct TerrainDef {
pub id: String,
pub glyph: char,
#[serde(default)]
pub opaque: bool,
#[serde(default)]
pub solid: bool,
}
#[derive(Deserialize, Clone)]
pub struct Terrain {
terrain: Vec<TerrainDef>,
}
impl ... | true |
2a06011aa2db6684b368cef9bd839937c549757e | Rust | russelltg/srt-rs | /srt-tokio/tests/high_bandwidth.rs | UTF-8 | 4,654 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use std::{
collections::VecDeque,
time::{Duration, Instant},
};
use anyhow::Error;
use bytes::Bytes;
use futures::{stream, FutureExt, SinkExt, Stream, StreamExt};
use log::{error, info};
use tokio::select;
use srt_tokio::{options::*, SocketStatistics, SrtSocket};
fn stream_exact(duration: Duration) -> impl S... | true |
e265e49700e5788e355685a9ede119e8396df348 | Rust | Senna46/linear-algebra-rs | /src/macros/zeros.rs | UTF-8 | 871 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{macros::sub_matrix::SubMatrix, number::Number};
#[macro_export]
macro_rules! zeros {
($e1: expr, $e2: expr) => {{
use $crate::macros::zeros::Zeros;
Zeros($e1, $e2)
}};
}
pub struct Zeros(pub usize, pub usize);
impl<U: Number> SubMatrix<U> for Zeros {
fn size(&self) -> (usize, usize) {
(... | true |
506cceb98cd4314d2c062057cb0a83bdf60cdad6 | Rust | scrogson/linked-list-rs | /src/fourth.rs | UTF-8 | 978 | 3.234375 | 3 | [] | no_license | use std::cell::RefCell;
use std::rc::Rc;
pub struct List<T> {
head: Link<T>,
tail: Link<T>,
}
type Link<T> = Option<Rc<RefCell<Node<T>>>>;
struct Node<T> {
elem: T,
next: Link<T>,
prev: Link<T>,
}
impl<T> Node<T> {
fn new(elem: T) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(Node {
... | true |
f692c0b62a319b062a413ff3a120209dde2a095b | Rust | pkornecki/rustconv | /tests/integration_test.rs | UTF-8 | 512 | 2.5625 | 3 | [] | no_license | use std::path::PathBuf;
#[tokio::test]
async fn conversion_works() {
let input = PathBuf::from("testdata/test-input.csv");
let output = PathBuf::from("testdata/test-output.csv");
let hotels = PathBuf::from("testdata/test-hotels.json");
rustconv::run(input, output.clone(), hotels).await.unwrap();
... | true |
52f595330ea65cb9cfa27ab76f2530b3d924e1f5 | Rust | jamesmcm/ruststorm | /src/shapes/frame.rs | UTF-8 | 3,819 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::errors::ShapesFileError;
use std::io::prelude::*;
use std::io::SeekFrom;
use byteorder::{LittleEndian, ReadBytesExt};
#[derive(Debug, PartialEq, Clone)]
pub struct Frame {
pub offset_from_unit: u32,
pub color_table: u32, // Always zero
pub data: FrameData,
}
impl Frame {
pub fn from_file_o... | true |
033ccc25fe2ca691af92e6e29285dab06c58b978 | Rust | andete/atsam4lc8c | /src/usbc/uhinte/mod.rs | UTF-8 | 11,702 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::UHINTE {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct DCONNIER {
bi... | true |
350145b76bf15ceb2aeb160ae11fb7eb6c91087e | Rust | ben0x539/rust-native-from-c | /counter.rs | UTF-8 | 3,682 | 3.046875 | 3 | [] | no_license | #![crate_type = "staticlib"] // could also compile with --crate-type=staticlib instead
extern crate native;
use std::io::timer::sleep;
use std::cast::transmute;
use std::libc::c_int;
// just some simple toy feature that exercises the rust runtime
pub struct Counter(Receiver<int>);
impl Counter {
pub fn new(coun... | true |
e2d13f4fc3addaeef7f3b17924a2970664c4d6e5 | Rust | mbwhite/fabric-contract-api-rust | /basic_contract_rs/src/types/myasset.rs | UTF-8 | 1,752 | 3.265625 | 3 | [
"Apache-2.0"
] | permissive |
/*
* SPDX-License-Identifier: Apache-2.0
*/
//! Very simple custom Asset object
// Use the required crates
use fabric_contract::data::*;
use fabric_contract::contract::*;
/// Basic definition of the asset object
///
/// Using Options here as this makes is possible to use the
/// Default trait to create a blank ... | true |
e8a82fa7baf151fd62cc60d2daac859e30df63ee | Rust | sunnyrust/rust_graceful_restart | /src/main.rs | UTF-8 | 3,067 | 2.640625 | 3 | [] | no_license | use signal_hook::consts::*;
use std::{
env::args,
io::{Read, Write},
net::{TcpListener, ToSocketAddrs},
os::unix::{
io::{AsRawFd, FromRawFd, RawFd},
process::CommandExt,
},
thread,
};
static mut LISTENER: Option<TcpListener> = None;
fn main() {
let pool = futures::executor::... | true |
1f0436045f933e2f3e1514a26a65bbf803ae6ca0 | Rust | aureentuluvacal/learn-rust | /src/chapter03/control_flow.rs | UTF-8 | 963 | 4.3125 | 4 | [] | no_license | fn loops(num_times: i32) {
let mut counter = 0;
let a = [10, 20, 30, 40, 50];
loop {
if counter == num_times {
break;
}
println!("I love crab rangoons!");
counter += 1;
}
while counter < 4 {
println!("More love!");
counter += 1;
}
... | true |
69a5f650fd74f492011a19aff1d2cb0af3e01fdd | Rust | AtsukiTak/atom-asm | /atom-macho/src/load_command/mod.rs | UTF-8 | 3,569 | 2.625 | 3 | [] | no_license | pub mod build_version;
pub mod dysymtab;
pub mod segment64;
pub mod symtab;
pub use self::{
build_version::{BuildToolVersion, BuildVersionCommand},
dysymtab::DysymtabCommand,
segment64::{Section64, SegmentCommand64},
symtab::SymtabCommand,
};
use crate::io::{Endian, ReadExt as _};
use byteorder::{BigE... | true |
a34558bf5623e62eb02072607b163fd0d738be2a | Rust | iamlouk/rhea | /tests/run-examples.rs | UTF-8 | 1,194 | 2.765625 | 3 | [] | no_license |
use std::process::Command;
use std::path::PathBuf;
fn run_example(name: &str) {
let mut script = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
script.push("examples/run-example.sh");
let status = Command::new("/bin/bash")
.args(&[script.to_str().unwrap(), name]).status();
assert!(status.is_ok()... | true |
8d8c5cee91a778c28c45ab33cf7e6cae289d173d | Rust | christopheslv/ray-tracing-iow | /src/vec3.rs | UTF-8 | 6,104 | 3.421875 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::ops::{Add, Sub, Mul, Div, AddAssign, MulAssign, DivAssign, Neg, Index, IndexMut};
use std::marker::{Copy};
use super::utils;
#[derive(Copy, Clone)]
pub struct Vec3 {
pub e: [f64; 3] // We could just use x,y,z attributes, kept an array to match book's "API"
}
pub type Point3 = Vec3;
pub t... | true |
fc5f95a1fb3075143794d7f1f0c726f65bd77cd7 | Rust | hgomez-sonarsource/Teddy | /src/handlers.rs | UTF-8 | 5,479 | 2.953125 | 3 | [] | no_license | extern crate iron;
extern crate params;
extern crate multipart;
use iron::prelude::*;
use std::path::Path;
use std::fs::File;
use std::fs;
use std::process::Command;
use iron::status;
use self::multipart::server::{Multipart, Entries, SaveResult};
use hyper::header::{ContentDisposition, DispositionType, DispositionPa... | true |
6a87d84b4024871c1bc83fa499004f933decc6f9 | Rust | jonasbb/exercism | /rust/roman-numerals/src/lib.rs | UTF-8 | 1,694 | 3.25 | 3 | [
"Unlicense"
] | permissive | pub struct Roman(u16);
impl Roman {
pub fn to_string(&self) -> String {
let mut res = String::new();
// the vector defines which letters to use for which position
for &(factor, oneer, fiveer, tener) in &[(1000, 'M', '-', '-'),
(100, 'C', 'D',... | true |
bc35200fd67c465e34553a8285c0e1419b690f74 | Rust | Holo-Host/hp-admin-crypto | /server/src/tests.rs | UTF-8 | 8,476 | 2.53125 | 3 | [
"MIT"
] | permissive | use super::*;
use base36;
use ed25519_dalek::{Keypair, Signer};
use hpos_config_core::config::admin_keypair_from;
const HC_PUBLIC_KEY: &str = "5m5srup6m3b2iilrsqmxu6ydp8p8cr0rdbh4wamupk3s4sxqr5";
const EMAIL: &str = "pj@abba.pl";
const PASSWORD: &str = "abbaabba";
#[test]
fn verify_hp_admin_match() {
let expected... | true |
178121a25ffc1060ec6a4fdcd0c7a697d19fc4a3 | Rust | HUSTERFZ/OS_Tutorial_Summer_of_Code | /Shell_Tools/minicat/src/core/read.rs | UTF-8 | 674 | 2.71875 | 3 | [] | no_license | /*
* Shell tools by Rust: mini cat
* 2020/7/7
* hustccc
* Manjaro
*/
use super::{Error,PathBuf,File,Read};
pub fn read_file(file: PathBuf) -> Result<String, Error> {
let temp_file = read(file)?;
Ok(temp_file)
}
fn read(path: PathBuf) -> Result<String, Error> {
let mut buffer = String::new();
let m... | true |
407902c6f05b34d81b2e3c5a4a2c8ef928b3e982 | Rust | lvheyang/fast-float-rust | /src/float.rs | UTF-8 | 3,595 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use core::fmt::{Debug, Display};
use core::ops::{Add, Div, Mul, Neg};
mod private {
pub trait Sealed {}
}
#[doc(hidden)]
pub trait Float:
Sized
+ private::Sealed
+ Div<Output = Self>
+ Neg<Output = Self>
+ Mul<Output = Self>
+ Add<Output = Self>
+ PartialEq
+ PartialOrd
+ Defau... | true |
04dd0a976aa6bd67dc855a7c71a646b808136982 | Rust | JonasRSV/Friday | /friday/friday-inference/src/lib.rs | UTF-8 | 1,142 | 3.265625 | 3 | [
"MIT"
] | permissive | use friday_error::FridayError;
#[derive(Debug, Clone)]
pub enum Prediction {
Result {
class: String,
},
Silence,
Inconclusive
}
pub trait Model {
fn reset(&mut self) -> Result<(), FridayError>;
fn predict(&mut self, v :&Vec<i16>) -> Result<Prediction, FridayError>;
fn expected_fr... | true |
af7de8b829accdecc80043564fcf6acbda972653 | Rust | FL33TW00D/rustDTW | /src/lib.rs | UTF-8 | 7,308 | 2.609375 | 3 | [
"MIT"
] | permissive | use indicatif::ParallelProgressIterator;
use ndarray::parallel::prelude::*;
use ndarray::prelude::*;
use pyo3::exceptions::PyValueError;
use pyo3::PyAny;
use std::error::Error;
use numpy::{
IntoPyArray, PyArray1, PyArrayDyn, PyReadonlyArray1, PyReadonlyArray2, PyReadonlyArray3,
};
use pyo3::conversion::FromPyObjec... | true |
e5601d1e1ac5a109a77406412d7c8eedbf69e04b | Rust | roberts-ivanovs/asteroid-wasm | /src/rust/src/gl_setup.rs | UTF-8 | 1,266 | 2.65625 | 3 | [
"MIT"
] | permissive | use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use web_sys::*;
use web_sys::{Document, HtmlCanvasElement, WebGlRenderingContext as GL};
fn wait_until_canvas_is_rendered(
document: Document,
canvas_id: &str,
) -> Result<HtmlCanvasElement, Element> {
let canvas: Option<Element> = document.get_element_b... | true |
d8d0fc2a96d0683f02ef8bf37fbb74fb352456ac | Rust | gaoxiaojun/day | /src/fractal.rs | UTF-8 | 3,743 | 3.15625 | 3 | [
"MIT"
] | permissive | use crate::{candle::Candle, time::Time};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FractalType {
Top,
Bottom,
}
// 分型
#[derive(Debug, Clone)]
pub struct Fractal {
pub(crate) k1: Candle,
pub(crate) k2: Candle,
pub(crate) k3: Candle,
// cache
ftype: FractalType,
}
// 计算分型之间K线的数量,... | true |
cb0ae822cd18cc5e180b95dd2ed077bb07bdd155 | Rust | exynoxx/rs-blockchain | /src/network.rs | UTF-8 | 5,254 | 2.9375 | 3 | [] | no_license | use bincode::{deserialize, serialize};
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::env;
use std::io::Read;
use std::io::Write;
use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream};
use std::net::TcpListener;
use std::sync::mpsc;
use std::sync::mpsc::Receiver;
use std:... | true |
30bc5834c5738f8bfa72604125153cab3cbd9e77 | Rust | terabyte/r4 | /operation/src/subop_options.rs | UTF-8 | 868 | 2.6875 | 3 | [] | no_license | use std::sync::Arc;
use super::StreamWrapper;
use validates::Validates;
#[derive(Default)]
pub struct SubOperationOption(Vec<String>);
impl SubOperationOption {
pub fn push(&mut self, a: &[String]) {
self.0.extend_from_slice(a);
}
pub fn of(a: Vec<String>) -> SubOperationOption {
return S... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.