file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
task_resolvers.rs | use chrono::{prelude::*};
use async_graphql::{Context, FieldResult, ID};
use eyre::{
eyre,
// Result,
// Context as _,
};
use super::{Task, TaskStatus, task_status::TaskStatusGQL};
use crate::{MachineMap, machine::{
MachineData,
messages::GetData,
}};
/// A spooled set of gcodes to be executed by... | (&self) -> Option<&DateTime<Utc>> {
use super::*;
match &self.status {
| TaskStatus::Finished(Finished { finished_at: t })
| TaskStatus::Paused(Paused { paused_at: t })
| TaskStatus::Cancelled(Cancelled { cancelled_at: t })
| TaskStatus::Errored(Errored {... | stopped_at | identifier_name |
event.rs | // Copyright 2015-2016, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use glib::translate::*;
use ffi as ffi;
use EventType;
use Window;
glib_wrapper! {
/// ... | }
impl AsRef<::ffi::$ffi_name> for $name {
#[inline]
fn as_ref(&self) -> &::ffi::$ffi_name {
unsafe {
let ptr: *const ::ffi::$ffi_name = self.to_glib_none().0;
&*ptr
}
}
}
impl A... | $name(from_glib_full(ptr as *mut ::ffi::GdkEvent))
} | random_line_split |
event.rs | // Copyright 2015-2016, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use glib::translate::*;
use ffi as ffi;
use EventType;
use Window;
glib_wrapper! {
/// ... | (&self) -> bool {
from_glib(self.as_ref().send_event as i32)
}
/// Returns `true` if the event type matches `T`.
pub fn is<T: FromEvent>(&self) -> bool {
T::is(self)
}
/// Tries to downcast to a specific event type.
pub fn downcast<T: FromEvent>(self) -> Result<T, Self> {
... | get_send_event | identifier_name |
event.rs | // Copyright 2015-2016, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use glib::translate::*;
use ffi as ffi;
use EventType;
use Window;
glib_wrapper! {
/// ... |
/// Returns the associated `Window` if applicable.
pub fn get_window(&self) -> Option<Window> {
unsafe { from_glib_none(self.as_ref().window) }
}
/// Returns whether the event was sent explicitly.
pub fn get_send_event(&self) -> bool {
from_glib(self.as_ref().send_event as i32)
... | {
self.as_ref().type_
} | identifier_body |
lib.rs | //#[deny(missing_docs)]
#[macro_use]
extern crate log;
extern crate gfx_core as core;
extern crate d3d11;
extern crate d3dcompiler;
extern crate dxgi;
extern crate dxguid;
extern crate winapi;
extern crate wio;
pub use self::data::map_format;
pub use self::device::Device;
mod command;
pub mod data;
mod execute;
mod ... |
fn pin_submitted_resources(&mut self, man: &handle::Manager<Resources>) {
self.frame_handles.extend(man);
match self.max_resource_count {
Some(c) if self.frame_handles.count() > c => {
error!("Way too many resources in the current frame. Did you call Device::cleanup()?"... | {
let _guard = self.before_submit(access).unwrap();
for submit in submit_infos {
for cb in submit.cmd_buffers {
unsafe { self.context.ClearState(); }
for com in &cb.parser.0 {
execute::process(&mut self.context, com, &cb.parser.1);
... | identifier_body |
lib.rs | //#[deny(missing_docs)]
#[macro_use]
extern crate log;
extern crate gfx_core as core;
extern crate d3d11;
extern crate d3dcompiler;
extern crate dxgi;
extern crate dxguid;
extern crate winapi;
extern crate wio;
pub use self::data::map_format;
pub use self::device::Device;
mod command;
pub mod data;
mod execute;
mod ... | }
unsafe impl Send for Program {}
unsafe impl Sync for Program {}
pub type InputLayout = *mut winapi::ID3D11InputLayout;
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Pipeline {
topology: winapi::D3D11_PRIMITIVE_TOPOLOGY,
layout: InputLayout,
vertex_buffers: [Option<core::pso::VertexBufferDesc>;... | hs: *mut winapi::ID3D11HullShader,
ds: *mut winapi::ID3D11DomainShader,
gs: *mut winapi::ID3D11GeometryShader,
ps: *mut winapi::ID3D11PixelShader,
vs_hash: u64, | random_line_split |
lib.rs | //#[deny(missing_docs)]
#[macro_use]
extern crate log;
extern crate gfx_core as core;
extern crate d3d11;
extern crate d3dcompiler;
extern crate dxgi;
extern crate dxguid;
extern crate winapi;
extern crate wio;
pub use self::data::map_format;
pub use self::device::Device;
mod command;
pub mod data;
mod execute;
mod ... | ;
pub struct Adapter {
adapter: ComPtr<winapi::IDXGIAdapter1>,
info: core::AdapterInfo,
queue_family: [(QueueFamily, QueueType); 1],
}
impl core::Adapter<Backend> for Adapter {
fn open(&self, queue_descs: &[(&QueueFamily, QueueType, u32)]) -> core::Gpu<Backend> {
// Only support a single queue... | Fence | identifier_name |
hello_world.rs | extern crate cocoa;
use cocoa::base::{selector, nil, YES, NO};
use cocoa::foundation::{NSUInteger, NSRect, NSPoint, NSSize,
NSAutoreleasePool, NSProcessInfo, NSString};
use cocoa::appkit::{NSApp,
NSApplication, NSApplicationActivationPolicyRegular,
NSWindow, NSTitledWindowMask, NSBackingStoreBuffered,
... | let _pool = NSAutoreleasePool::new(nil);
let app = NSApp();
app.setActivationPolicy_(NSApplicationActivationPolicyRegular);
// create Menu Bar
let menubar = NSMenu::new(nil).autorelease();
let app_menu_item = NSMenuItem::new(nil).autorelease();
menubar.addItem_(app_menu_item);
app.setMainMenu_(menubar... | random_line_split | |
hello_world.rs | extern crate cocoa;
use cocoa::base::{selector, nil, YES, NO};
use cocoa::foundation::{NSUInteger, NSRect, NSPoint, NSSize,
NSAutoreleasePool, NSProcessInfo, NSString};
use cocoa::appkit::{NSApp,
NSApplication, NSApplicationActivationPolicyRegular,
NSWindow, NSTitledWindowMask, NSBackingStoreBuffered,
... | let quit_key = NSString::alloc(nil).init_str("q");
let quit_item = NSMenuItem::alloc(nil).initWithTitle_action_keyEquivalent_(
quit_title,
quit_action,
quit_key
).autorelease();
app_menu.addItem_(quit_item);
app_menu_item.setSubmenu_(app_menu);
// create Window
let window = NSWindow::alloc(nil).... | {
unsafe {
let _pool = NSAutoreleasePool::new(nil);
let app = NSApp();
app.setActivationPolicy_(NSApplicationActivationPolicyRegular);
// create Menu Bar
let menubar = NSMenu::new(nil).autorelease();
let app_menu_item = NSMenuItem::new(nil).autorelease();
menubar.addItem_(app_menu_item);
app.setMainM... | identifier_body |
hello_world.rs | extern crate cocoa;
use cocoa::base::{selector, nil, YES, NO};
use cocoa::foundation::{NSUInteger, NSRect, NSPoint, NSSize,
NSAutoreleasePool, NSProcessInfo, NSString};
use cocoa::appkit::{NSApp,
NSApplication, NSApplicationActivationPolicyRegular,
NSWindow, NSTitledWindowMask, NSBackingStoreBuffered,
... | () {
unsafe {
let _pool = NSAutoreleasePool::new(nil);
let app = NSApp();
app.setActivationPolicy_(NSApplicationActivationPolicyRegular);
// create Menu Bar
let menubar = NSMenu::new(nil).autorelease();
let app_menu_item = NSMenuItem::new(nil).autorelease();
menubar.addItem_(app_menu_item);
app.setMa... | main | identifier_name |
windowing.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
use compositor... | /// Returns the rendering area size in hardware pixels.
fn framebuffer_size(&self) -> DeviceUintSize;
/// Returns the position and size of the window within the rendering area.
fn window_rect(&self) -> DeviceUintRect;
/// Returns the size of the window in density-independent "px" units.
fn size(... | pub trait WindowMethods { | random_line_split |
windowing.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
use compositor... | {
Click(MouseButton, TypedPoint2D<f32, DevicePixel>),
MouseDown(MouseButton, TypedPoint2D<f32, DevicePixel>),
MouseUp(MouseButton, TypedPoint2D<f32, DevicePixel>),
}
/// Events that the windowing system sends to Servo.
#[derive(Clone)]
pub enum WindowEvent {
/// Sent when no message has arrived, but t... | MouseWindowEvent | identifier_name |
internal_unstable.rs | // Copyright 2015 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 | #![feature(staged_api, allow_internal_unstable)]
#![staged_api]
#![stable(feature = "stable", since = "1.0.0")]
#[unstable(feature = "function")]
pub fn unstable() {}
#[stable(feature = "stable", since = "1.0.0")]
pub struct Foo {
#[unstable(feature = "struct_field")]
pub x: u8
}
#[allow_internal_unstable]
... | // 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 distributed
// except according to those terms.
| random_line_split |
internal_unstable.rs | // Copyright 2015 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 ... | {
#[unstable(feature = "struct_field")]
pub x: u8
}
#[allow_internal_unstable]
#[macro_export]
macro_rules! call_unstable_allow {
() => { $crate::unstable() }
}
#[allow_internal_unstable]
#[macro_export]
macro_rules! construct_unstable_allow {
($e: expr) => {
$crate::Foo { x: $e }
}
}
#[... | Foo | identifier_name |
sync.rs | use core::ops::{Deref, DerefMut};
use kernel::sched::{task_locked, task_unlocked};
use arch::int::{disable_interrupts, enable_interrupts};
use spin::{Mutex as M, MutexGuard as MG};
pub struct Mutex<T> {
l: M<T>,
}
pub struct MutexGuard<'a, T:?Sized + 'a> {
g: Option<MG<'a, T>>,
irq: bool,
task_locked:... |
pub fn lock_irq(&self) -> MutexGuard<T> {
disable_interrupts();
task_locked();
MutexGuard {
g: Some(self.l.lock()),
irq: true,
task_locked: true
}
}
}
impl<'a, T:?Sized> Deref for MutexGuard<'a, T> {
type Target = T;
fn deref<'b>(&'b... | {
task_locked();
MutexGuard {
g: Some(self.l.lock()),
irq: false,
task_locked: true
}
} | identifier_body |
sync.rs | use core::ops::{Deref, DerefMut};
use kernel::sched::{task_locked, task_unlocked};
use arch::int::{disable_interrupts, enable_interrupts};
use spin::{Mutex as M, MutexGuard as MG};
pub struct Mutex<T> {
l: M<T>,
}
pub struct MutexGuard<'a, T:?Sized + 'a> {
g: Option<MG<'a, T>>,
irq: bool,
task_locked:... | (&self) -> MutexGuard<T> {
disable_interrupts();
task_locked();
MutexGuard {
g: Some(self.l.lock()),
irq: true,
task_locked: true
}
}
}
impl<'a, T:?Sized> Deref for MutexGuard<'a, T> {
type Target = T;
fn deref<'b>(&'b self) -> &'b T {
... | lock_irq | identifier_name |
sync.rs | use core::ops::{Deref, DerefMut};
use kernel::sched::{task_locked, task_unlocked};
use arch::int::{disable_interrupts, enable_interrupts};
use spin::{Mutex as M, MutexGuard as MG};
pub struct Mutex<T> {
l: M<T>,
}
pub struct MutexGuard<'a, T:?Sized + 'a> {
g: Option<MG<'a, T>>,
irq: bool,
task_locked:... |
if self.irq {
enable_interrupts();
}
}
} | {
task_unlocked();
} | conditional_block |
sync.rs | use core::ops::{Deref, DerefMut};
use kernel::sched::{task_locked, task_unlocked};
use arch::int::{disable_interrupts, enable_interrupts};
use spin::{Mutex as M, MutexGuard as MG};
pub struct Mutex<T> {
l: M<T>,
}
pub struct MutexGuard<'a, T:?Sized + 'a> {
g: Option<MG<'a, T>>,
irq: bool, | }
impl<T> Mutex<T> {
pub const fn new(user_data: T) -> Mutex<T> {
Mutex {
l: M::new(user_data),
}
}
pub fn lock(&self) -> MutexGuard<T> {
task_locked();
MutexGuard {
g: Some(self.l.lock()),
irq: false,
task_locked: true
... | task_locked: bool | random_line_split |
capture_nil.rs | // Copyright 2012 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 ... | (x: ()) -> Receiver<()> {
let (tx, rx) = channel::<()>();
task::spawn(proc() {
tx.send(x);
});
rx
}
pub fn main() {
foo(()).recv()
}
| foo | identifier_name |
capture_nil.rs | // Copyright 2012 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 ... |
pub fn main() {
foo(()).recv()
}
| {
let (tx, rx) = channel::<()>();
task::spawn(proc() {
tx.send(x);
});
rx
} | identifier_body |
capture_nil.rs | // Copyright 2012 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 ... | } |
pub fn main() {
foo(()).recv() | random_line_split |
logger.rs | use colored::*;
use env_logger::LogBuilder;
use log::{LogRecord, LogLevel, LogLevelFilter};
use std::env;
pub fn init() |
builder.init().unwrap();
}
| {
let format = |record: &LogRecord| {
let level = format!("{: <5}", record.level());
let levelc = match record.level() {
LogLevel::Trace => level.dimmed().yellow(),
LogLevel::Debug => level.black().on_yellow(),
LogLevel::Info => level.green().bold(),
L... | identifier_body |
logger.rs | use colored::*;
use env_logger::LogBuilder;
use log::{LogRecord, LogLevel, LogLevelFilter};
use std::env;
pub fn init() {
let format = |record: &LogRecord| {
let level = format!("{: <5}", record.level());
let levelc = match record.level() {
LogLevel::Trace => level.dimmed().yellow(),
... |
let mut builder = LogBuilder::new();
builder.format(format).filter(None, LogLevelFilter::Warn);
if env::var("RUST_LOG").is_ok() {
builder.parse(&env::var("RUST_LOG").unwrap());
}
builder.init().unwrap();
} | }; | random_line_split |
logger.rs | use colored::*;
use env_logger::LogBuilder;
use log::{LogRecord, LogLevel, LogLevelFilter};
use std::env;
pub fn | () {
let format = |record: &LogRecord| {
let level = format!("{: <5}", record.level());
let levelc = match record.level() {
LogLevel::Trace => level.dimmed().yellow(),
LogLevel::Debug => level.black().on_yellow(),
LogLevel::Info => level.green().bold(),
... | init | identifier_name |
issue-46576.rs | // Copyright 2017 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 ... |
fn main() {}
| {
for _line in s.lines() {
}
} | identifier_body |
issue-46576.rs | // Copyright 2017 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 ... | (s: &str) {
for _line in s.lines() {
}
}
fn main() {}
| read_lines | identifier_name |
issue-46576.rs | // Copyright 2017 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... | random_line_split | |
dot.rs | // Copyright (c) 2015, The Radare Project. All rights reserved.
// See the COPYING file at the top-level directory of this distribution.
// Licensed under the BSD 3-Clause License:
// <http://opensource.org/licenses/BSD-3-Clause>
// This file may not be copied, modified, or distributed
// except according to those term... | else {
let mut t = " [".to_string();
for &(ref k, ref v) in attrs {
t.push_str(&*format!(" {}={}", k, v));
}
t.push_str(" ]");
t
}
}
_ => unreachable!(),
... | {
"".to_owned()
} | conditional_block |
dot.rs | // Copyright (c) 2015, The Radare Project. All rights reserved.
// See the COPYING file at the top-level directory of this distribution.
// Licensed under the BSD 3-Clause License:
// <http://opensource.org/licenses/BSD-3-Clause>
// This file may not be copied, modified, or distributed
// except according to those term... | (&mut self) -> &String {
let mut r = String::new();
let attr = if let DotAttrBlock::Hybrid(ref s, ref attr) = *self {
r.push_str(s);
attr.clone()
} else {
Vec::new()
};
if!attr.is_empty() {
*self = DotAttrBlock::Attributes(attr);
... | bake | identifier_name |
dot.rs | // Copyright (c) 2015, The Radare Project. All rights reserved.
// See the COPYING file at the top-level directory of this distribution.
// Licensed under the BSD 3-Clause License:
// <http://opensource.org/licenses/BSD-3-Clause>
// This file may not be copied, modified, or distributed
// except according to those term... |
use std::cmp::Eq;
use std::collections::HashMap;
use std::fmt::Debug;
use std::hash::Hash;
use petgraph::graph::NodeIndex;
#[allow(unused_macros)]
macro_rules! add_strings {
( $( $x: expr ),* ) => {
{
let mut s = String::new();
$(
s.push_str(&format!("{}", $x));
... | random_line_split | |
keyboard.rs | use alloc::borrow::ToOwned;
use alloc::string::String;
use alloc::vec::Vec;
use hashbrown::HashSet;
use d7keymap::{KeyAction, KeyCodes, KeyMap, KeySymbol};
use libd7::ipc::{self, protocol::keyboard::KeyboardEvent};
pub struct Keyboard {
keycodes: KeyCodes,
keymap: KeyMap,
pub pressed_modifiers: HashSet<Ke... |
}
#[derive(Debug)]
#[must_use]
pub enum EventAction {
KeyAction(KeyAction),
Unmatched(KeySymbol, HashSet<KeySymbol>),
Ignore,
NoSuchSymbol,
}
| {
for (k, v) in &self.keymap.mapping {
if k.matches(keysym, &self.pressed_modifiers) {
return Some(if let KeyAction::Remap(to) = v.clone() {
self.process_keysym_press(&to)?
} else {
v.clone()
});
}
... | identifier_body |
keyboard.rs | use alloc::borrow::ToOwned;
use alloc::string::String;
use alloc::vec::Vec;
use hashbrown::HashSet;
use d7keymap::{KeyAction, KeyCodes, KeyMap, KeySymbol};
use libd7::ipc::{self, protocol::keyboard::KeyboardEvent};
pub struct Keyboard {
keycodes: KeyCodes,
keymap: KeyMap,
pub pressed_modifiers: HashSet<Ke... | (&mut self, keysym: &KeySymbol) -> Option<KeyAction> {
for (k, v) in &self.keymap.mapping {
if k.matches(keysym, &self.pressed_modifiers) {
return Some(if let KeyAction::Remap(to) = v.clone() {
self.process_keysym_press(&to)?
} else {
... | process_keysym_press | identifier_name |
keyboard.rs | use alloc::borrow::ToOwned;
use alloc::string::String;
use alloc::vec::Vec;
use hashbrown::HashSet;
use d7keymap::{KeyAction, KeyCodes, KeyMap, KeySymbol};
use libd7::ipc::{self, protocol::keyboard::KeyboardEvent};
pub struct Keyboard {
keycodes: KeyCodes,
keymap: KeyMap,
pub pressed_modifiers: HashSet<Ke... | Unmatched(KeySymbol, HashSet<KeySymbol>),
Ignore,
NoSuchSymbol,
} | random_line_split | |
keyboard.rs | use alloc::borrow::ToOwned;
use alloc::string::String;
use alloc::vec::Vec;
use hashbrown::HashSet;
use d7keymap::{KeyAction, KeyCodes, KeyMap, KeySymbol};
use libd7::ipc::{self, protocol::keyboard::KeyboardEvent};
pub struct Keyboard {
keycodes: KeyCodes,
keymap: KeyMap,
pub pressed_modifiers: HashSet<Ke... |
}
pub fn process_keysym_press(&mut self, keysym: &KeySymbol) -> Option<KeyAction> {
for (k, v) in &self.keymap.mapping {
if k.matches(keysym, &self.pressed_modifiers) {
return Some(if let KeyAction::Remap(to) = v.clone() {
self.process_keysym_press(&to)?... | {
EventAction::NoSuchSymbol
} | conditional_block |
thumbnail2.rs | //! Super Mario Maker 2 thumbnail file manipulation.
use crate::decrypt;
use crate::key_tables::*;
use image::jpeg::JPEGEncoder;
use image::{load_from_memory, DynamicImage, ImageError};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
#[cfg_attr(feature = "wasm", wasm_bindgen)]
#[derive(Clone, Debug, PartialEq... | else {
Some(jpeg.to_vec())
};
Ok(())
}
_ => Ok(()),
}
}
fn lazy_load_jpeg(&mut self) {
let decrypted = if self.jpeg.is_none() {
Some(decrypt(self.encrypted.clone(), &THUMBNAIL_KEY_TABLE))
} else {
... | {
Some(opt)
} | conditional_block |
thumbnail2.rs | use crate::key_tables::*;
use image::jpeg::JPEGEncoder;
use image::{load_from_memory, DynamicImage, ImageError};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
#[cfg_attr(feature = "wasm", wasm_bindgen)]
#[derive(Clone, Debug, PartialEq)]
pub struct Thumbnail2 {
encrypted: Vec<u8>,
jpeg: Option<Vec<u8... | //! Super Mario Maker 2 thumbnail file manipulation.
use crate::decrypt; | random_line_split | |
thumbnail2.rs | //! Super Mario Maker 2 thumbnail file manipulation.
use crate::decrypt;
use crate::key_tables::*;
use image::jpeg::JPEGEncoder;
use image::{load_from_memory, DynamicImage, ImageError};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
#[cfg_attr(feature = "wasm", wasm_bindgen)]
#[derive(Clone, Debug, PartialEq... | (&self) -> &Vec<u8> {
&self.encrypted
}
pub fn move_jpeg(&mut self) -> Vec<u8> {
self.lazy_load_jpeg();
self.jpeg.clone().unwrap()
}
pub fn get_jpeg(&mut self) -> &[u8] {
self.lazy_load_jpeg();
if let Some(jpeg) = &self.jpeg_opt {
&jpeg[..]
}... | get_encrypted | identifier_name |
thumbnail2.rs | //! Super Mario Maker 2 thumbnail file manipulation.
use crate::decrypt;
use crate::key_tables::*;
use image::jpeg::JPEGEncoder;
use image::{load_from_memory, DynamicImage, ImageError};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
#[cfg_attr(feature = "wasm", wasm_bindgen)]
#[derive(Clone, Debug, PartialEq... |
pub fn get_jpeg(&mut self) -> &[u8] {
self.lazy_load_jpeg();
if let Some(jpeg) = &self.jpeg_opt {
&jpeg[..]
} else {
self.jpeg.as_ref().unwrap()
}
}
pub fn get_jpeg_no_opt(&mut self) -> &[u8] {
self.lazy_load_jpeg();
self.jpeg.as_ref... | {
self.lazy_load_jpeg();
self.jpeg.clone().unwrap()
} | identifier_body |
time_decoder.rs | /**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| ... | (r: &mut Reader) -> Result {
r.read_string_without_tag()
.and_then(|s| strptime(&s, "%F %T.%f %z").map_err(|e| DecoderError::ParserError(ParserError::ParseTimeError(e))))
}
| read_string_as_time | identifier_name |
time_decoder.rs | /**********************************************************\ | | |
\**********************************************************/
/**********************************************************\
* *
* io/decoders/time_decoder.rs *
* ... | | |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ | | random_line_split |
time_decoder.rs | /**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| ... |
fn read_long_as_time(r: &mut Reader) -> Result {
r.byte_reader.read_i64()
.map(|i| at_utc(Timespec::new(i, 0)))
.map_err(|e| DecoderError::ParserError(e))
}
fn read_float_as_time(r: &mut Reader) -> Result {
r.byte_reader.read_f64()
.map(|f| at_utc(Timespec::new(f as i64, 0)))
.map... | {
match tag {
b @ b'0' ... b'9' => Ok(at_utc(Timespec::new((b - b'0') as i64, 0))),
TAG_INTEGER | TAG_LONG => read_long_as_time(r),
TAG_DOUBLE => read_float_as_time(r),
TAG_STRING => read_string_as_time(r),
TAG_DATE => r.read_datetime_without_tag(),
TAG_TIME => r.read... | identifier_body |
mem.rs | // Copyright 2012-2014 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-MI... | /// // Perform the swap, `&mut` pointers never alias
/// ptr::copy_nonoverlapping(&*x, &mut t, 1);
/// ptr::copy_nonoverlapping(&*y, x, 1);
/// ptr::copy_nonoverlapping(&t, y, 1);
///
/// // y and t now point to the same thing, but we need to completely
/// // forget `t` ... | /// unsafe {
/// // Give ourselves some scratch space to work with
/// let mut t: T = mem::uninitialized();
/// | random_line_split |
mem.rs | // Copyright 2012-2014 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-MI... | <T>(_x: T) { }
macro_rules! repeat_u8_as_u32 {
($name:expr) => { (($name as u32) << 24 |
($name as u32) << 16 |
($name as u32) << 8 |
($name as u32)) }
}
macro_rules! repeat_u8_as_u64 {
($name:expr) => { ((repeat_u8_as_u32!($name) as u64) <<... | drop | identifier_name |
mem.rs | // Copyright 2012-2014 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-MI... |
/// Returns the alignment in memory for a type.
///
/// This is the alignment used for struct fields. It may be smaller than the preferred alignment.
///
/// # Examples
///
/// ```
/// use std::mem;
///
/// assert_eq!(4, mem::align_of::<i32>());
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn a... | {
unsafe { intrinsics::min_align_of_val(val) }
} | identifier_body |
player.rs | use graphics::{Context, Polygon, Transformed};
use opengl_graphics::GlGraphics;
use rand::Rng;
use drawing::{color, Point, Size};
use super::Vector;
use traits::{Advance, Collide, Position};
/// The `Player` is the rocket controlled by the user
#[derive(Default)]
pub struct Player {
pub vector: Vector
... | fn radius(&self) -> f64 { 6.0 }
} | random_line_split | |
player.rs | use graphics::{Context, Polygon, Transformed};
use opengl_graphics::GlGraphics;
use rand::Rng;
use drawing::{color, Point, Size};
use super::Vector;
use traits::{Advance, Collide, Position};
/// The `Player` is the rocket controlled by the user
#[derive(Default)]
pub struct Player {
pub vector: Vector
... | <R: Rng>(rng: &mut R, bounds: Size) -> Player {
Player { vector: Vector::random(rng, bounds) }
}
/// Draw the player
pub fn draw(&self, c: &Context, gl: &mut GlGraphics) {
// Set the center of the player as the origin and rotate it
let transform = c.transform.trans(self.x(), ... | random | identifier_name |
parallel-letter-frequency.rs | use std::collections::HashMap;
extern crate parallel_letter_frequency as frequency;
// Poem by Friedrich Schiller. The corresponding music is the European Anthem.
const ODE_AN_DIE_FREUDE: [&'static str; 8] = [
"Freude schöner Götterfunken",
"Tochter aus Elysium,",
"Wir betreten feuertrunken,",
"Himmli... | let mut v = Vec::with_capacity(1000);
for _ in 0..1000 {
v.push("abc");
}
let mut hm = HashMap::new();
hm.insert('a', 1000);
hm.insert('b', 1000);
hm.insert('c', 1000);
assert_eq!(frequency::frequency(&v[..], 4), hm);
}
#[test]
#[ignore]
fn test_punctuation_doesnt_count() {
... | many_times_same_text() {
| identifier_name |
parallel-letter-frequency.rs | use std::collections::HashMap;
extern crate parallel_letter_frequency as frequency;
// Poem by Friedrich Schiller. The corresponding music is the European Anthem.
const ODE_AN_DIE_FREUDE: [&'static str; 8] = [
"Freude schöner Götterfunken",
"Tochter aus Elysium,",
"Wir betreten feuertrunken,",
"Himmli... | est]
#[ignore]
fn test_all_three_anthems_1_worker() {
let mut v = Vec::new();
for anthem in [ODE_AN_DIE_FREUDE, WILHELMUS, STAR_SPANGLED_BANNER].iter() {
for line in anthem.iter() {
v.push(*line);
}
}
let freqs = frequency::frequency(&v[..], 1);
assert_eq!(freqs.get(&'a')... | assert!(!frequency::frequency(&["Testing, 1, 2, 3"], 4).contains_key(&'1'));
}
#[t | identifier_body |
parallel-letter-frequency.rs | use std::collections::HashMap;
extern crate parallel_letter_frequency as frequency;
// Poem by Friedrich Schiller. The corresponding music is the European Anthem.
const ODE_AN_DIE_FREUDE: [&'static str; 8] = [
"Freude schöner Götterfunken",
"Tochter aus Elysium,",
"Wir betreten feuertrunken,",
"Himmli... | "O'er the land of the free and the home of the brave?"];
#[test]
fn test_no_texts() {
assert_eq!(frequency::frequency(&[], 4), HashMap::new());
}
#[test]
#[ignore]
fn test_one_letter() {
let mut hm = HashMap::new();
hm.insert('a', 1);
assert_eq!(frequency::frequency(&["a"], 4), hm);
}
#[test]
#[i... | random_line_split | |
raw.rs | #![allow(non_camel_case_types)]
use std::os::raw::{c_int, c_char, c_uchar};
#[link(name = "git2")]
extern "C" {
pub fn git_libgit2_init() -> c_int;
pub fn git_libgit2_shutdown() -> c_int;
pub fn giterr_last() -> *const git_error;
pub fn git_repository_open(out: *mut *mut git_repository, path: *const ... | pub message: *const c_char,
pub klass: c_int,
}
#[repr(C)]
pub struct git_oid {
pub id: [c_uchar; 20],
}
pub type git_time_t = i64;
#[repr(C)]
pub struct git_time {
pub time: git_time_t,
pub offset: c_int,
}
#[repr(C)]
pub struct git_signature {
pub name: *const c_char,
pub email: *const... | pub struct git_error { | random_line_split |
raw.rs | #![allow(non_camel_case_types)]
use std::os::raw::{c_int, c_char, c_uchar};
#[link(name = "git2")]
extern "C" {
pub fn git_libgit2_init() -> c_int;
pub fn git_libgit2_shutdown() -> c_int;
pub fn giterr_last() -> *const git_error;
pub fn git_repository_open(out: *mut *mut git_repository, path: *const ... | {
pub time: git_time_t,
pub offset: c_int,
}
#[repr(C)]
pub struct git_signature {
pub name: *const c_char,
pub email: *const c_char,
pub when: git_time,
}
| git_time | identifier_name |
window.rs | use ::rendering::DrawBatch;
use ::resources::ResourceManager;
use super::BorderImage;
use super::{Widget, Rectangle, EventListener};
use glium;
use std::option::Option;
use std::rc::Rc;
use std::cell::RefCell;
const PADDING: i32 = 5;
pub struct Window<'a> {
rect: Rectangle,
draw_batch: DrawBatch<'a>,
wind... |
}
pub fn create_event_listener(&self, x: i32, y: i32) -> Option<Box<EventListener>> {
if let Some(ref child) = self.child {
let (i, widget) = child.borrow().get_highest_priority_child(x, y);
if let Some(widget) = widget {
println!("{}", i);
retur... | {
let (i, _) = child.borrow().get_highest_priority_child(x, y);
println!("{}", i);
} | conditional_block |
window.rs | use ::rendering::DrawBatch;
use ::resources::ResourceManager;
use super::BorderImage;
use super::{Widget, Rectangle, EventListener};
use glium;
use std::option::Option;
use std::rc::Rc;
use std::cell::RefCell;
const PADDING: i32 = 5;
pub struct Window<'a> {
rect: Rectangle,
draw_batch: DrawBatch<'a>,
wind... | self.child = Some(child);
}
pub fn create_buffers(&mut self) {
self.draw_batch.clear();
self.window_background.add_to_batch(&mut self.draw_batch);
if let Some(ref child) = self.child {
child.borrow_mut().set_dimensions(self.rect.dimensions.0 - 2 * PADDING, self.rect.... | }
pub fn set_child(&mut self, child: Rc<RefCell<Widget>>) { | random_line_split |
window.rs | use ::rendering::DrawBatch;
use ::resources::ResourceManager;
use super::BorderImage;
use super::{Widget, Rectangle, EventListener};
use glium;
use std::option::Option;
use std::rc::Rc;
use std::cell::RefCell;
const PADDING: i32 = 5;
pub struct Window<'a> {
rect: Rectangle,
draw_batch: DrawBatch<'a>,
wind... |
}
| {
self.draw_batch.draw(frame);
} | identifier_body |
window.rs | use ::rendering::DrawBatch;
use ::resources::ResourceManager;
use super::BorderImage;
use super::{Widget, Rectangle, EventListener};
use glium;
use std::option::Option;
use std::rc::Rc;
use std::cell::RefCell;
const PADDING: i32 = 5;
pub struct Window<'a> {
rect: Rectangle,
draw_batch: DrawBatch<'a>,
wind... | (
resource_manager: &mut ResourceManager,
display: &'a glium::backend::glutin_backend::GlutinFacade,
x: i32,
y: i32,
width: i32,
height: i32
) -> Window<'a> {
let texture = resource_manager.create_texture("example_images/window_sq.png").unwrap();
let m... | new | identifier_name |
inpaint.rs | // Inpainting is applied to fill holes in the X-ray quadtree leaf tiles.
// As inpainting depends on sampling the neighborhood of pixels, if we
// directly took the original tiles as input, we would get visible color
// differences for the inpainted pixels along the tile borders. Because
// of this we enlarge all tiles... | );
current.save(current_path)?;
neighbor.save(neighbor_path)?;
}
Ok(())
}
fn apply_inpainting(&self) -> ImageResult<()> {
if let Some((inpaint_image, inpaint_image_path)) = self.inpaint_image_and_path_from(None)? {
let (width, height) = i... | {
let (width, height) = match direction {
Direction::Right => (current.width() / 2, current.height()),
Direction::Bottom => (current.width(), current.height() / 2),
_ => unimplemented!(),
};
let ((current_x, current_y), (neighbor_x, nei... | conditional_block |
inpaint.rs | // Inpainting is applied to fill holes in the X-ray quadtree leaf tiles.
// As inpainting depends on sampling the neighborhood of pixels, if we
// directly took the original tiles as input, we would get visible color
// differences for the inpainted pixels along the tile borders. Because
// of this we enlarge all tiles... | )?;
inpainting.step(
"Horizontally interpolating inpaint images",
// Interleave interpolation to avoid race conditions when writing images
|spatial_node_id| spatial_node_id.x() % 2 == 0,
|inpainter| inpainter.interpolate_inpaint_image_with(Direction::Right),
)?;
inpaint... | {
if inpaint_distance_px == 0 {
return Ok(());
}
let spatial_node_ids: Vec<SpatialNodeId> = leaf_node_ids
.iter()
.cloned()
.map(SpatialNodeId::from)
.collect();
let inpainting = Inpainting {
output_directory,
spatial_node_ids,
};
inpain... | identifier_body |
inpaint.rs | // Inpainting is applied to fill holes in the X-ray quadtree leaf tiles.
// As inpainting depends on sampling the neighborhood of pixels, if we
// directly took the original tiles as input, we would get visible color
// differences for the inpainted pixels along the tile borders. Because
// of this we enlarge all tiles... | (&self, neighbor: impl Into<Option<Direction>>) -> Option<SpatialNodeId> {
match neighbor.into() {
Some(n) => self.spatial_node_id.neighbor(n),
None => Some(self.spatial_node_id),
}
}
fn image_from(&self, neighbor: impl Into<Option<Direction>>) -> ImageResult<Option<Rgba... | spatial_id_from | identifier_name |
inpaint.rs | // Inpainting is applied to fill holes in the X-ray quadtree leaf tiles.
// As inpainting depends on sampling the neighborhood of pixels, if we
// directly took the original tiles as input, we would get visible color
// differences for the inpainted pixels along the tile borders. Because
// of this we enlarge all tiles... | };
let neighbor_weighting_function: Box<dyn Fn(u32, u32) -> f32> = match direction {
Direction::Right => Box::new(|i, _| i as f32 / (width - 1) as f32),
Direction::Bottom => Box::new(|_, j| j as f32 / (height - 1) as f32),
_ => unimplemented!(),
... | _ => unimplemented!(), | random_line_split |
markup.rs | use serde_derive::{Deserialize, Serialize};
use syntect::parsing::SyntaxSet;
pub const DEFAULT_HIGHLIGHT_THEME: &str = "base16-ocean-dark";
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct Markdown {
/// Whether to highlight all code blocks found in markdown files. Defaults to false
... | se {
format!("rel=\"{}\" ", rel_opts.join(" "))
};
format!("<a {}{}{}href=\"{}\">", rel, target, title, url)
}
}
impl Default for Markdown {
fn default() -> Markdown {
Markdown {
highlight_code: false,
highlight_theme: DEFAULT_HIGHLIGHT_THEME.to_owne... | "".to_owned()
} el | conditional_block |
markup.rs | use serde_derive::{Deserialize, Serialize};
use syntect::parsing::SyntaxSet;
pub const DEFAULT_HIGHLIGHT_THEME: &str = "base16-ocean-dark";
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct Markdown {
/// Whether to highlight all code blocks found in markdown files. Defaults to false
... | } | random_line_split | |
markup.rs | use serde_derive::{Deserialize, Serialize};
use syntect::parsing::SyntaxSet;
pub const DEFAULT_HIGHLIGHT_THEME: &str = "base16-ocean-dark";
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct Markdown {
/// Whether to highlight all code blocks found in markdown files. Defaults to false
... | elf, url: &str, title: &str) -> String {
let mut rel_opts = Vec::new();
let mut target = "".to_owned();
let title = if title == "" { "".to_owned() } else { format!("title=\"{}\" ", title) };
if self.external_links_target_blank {
// Security risk otherwise
rel_opt... | struct_external_link_tag(&s | identifier_name |
screen.rs |
use dom::bindings::codegen::Bindings::ScreenBinding;
use dom::bindings::codegen::Bindings::ScreenBinding::ScreenMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::DomRoot;
use dom::window::Window;
use dom_struct::dom_struct;
#[dom_struct]
pub struct Screen {
reflector... | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | random_line_split | |
screen.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::ScreenBinding;
use dom::bindings::codegen::Bindings::ScreenBinding::ScreenMe... |
}
| {
24
} | identifier_body |
screen.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::ScreenBinding;
use dom::bindings::codegen::Bindings::ScreenBinding::ScreenMe... | (&self) -> u32 {
24
}
}
| PixelDepth | identifier_name |
service.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | }
}
}
/// IO Service with networking
/// `Message` defines a notification data type.
pub struct NetworkService {
io_service: IoService<NetworkIoMessage>,
host_info: String,
host: RwLock<Option<Arc<Host>>>,
stats: Arc<NetworkStats>,
panic_handler: Arc<PanicHandler>,
host_handler: Arc<HostHandler>,
config: Net... | *url = Some(public_url.to_owned()); | random_line_split |
service.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... |
/// Returns host identifier string as advertised to other peers
pub fn host_info(&self) -> String {
self.host_info.clone()
}
/// Returns underlying io service.
pub fn io(&self) -> &IoService<NetworkIoMessage> {
&self.io_service
}
/// Returns network statistics.
pub fn stats(&self) -> &NetworkStats {
&... | {
try!(self.io_service.send_message(NetworkIoMessage::AddHandler {
handler: handler,
protocol: protocol,
versions: versions.to_vec(),
packet_count: packet_count,
}));
Ok(())
} | identifier_body |
service.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | (&self) -> Option<String> {
let host = self.host.read();
host.as_ref().and_then(|h| h.external_url())
}
/// Returns external url if available.
pub fn local_url(&self) -> Option<String> {
let host = self.host.read();
host.as_ref().map(|h| h.local_url())
}
/// Start network IO
pub fn start(&self) -> Resul... | external_url | identifier_name |
service.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | else {
Ok(())
}
}
/// Try to remove a reserved peer.
pub fn remove_reserved_peer(&self, peer: &str) -> Result<(), NetworkError> {
let host = self.host.read();
if let Some(ref host) = *host {
host.remove_reserved_node(peer)
} else {
Ok(())
}
}
/// Set the non-reserved peer mode.
pub fn set_no... | {
host.add_reserved_node(peer)
} | conditional_block |
htmllielement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLLIElementBinding;
use dom::bindings::utils::{DOMString, ErrorResult};
use dom::doc... |
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(())
}
}
| {
~""
} | identifier_body |
htmllielement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLLIElementBinding;
use dom::bindings::utils::{DOMString, ErrorResult};
use dom::doc... | }
pub fn Type(&self) -> DOMString {
~""
}
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(())
}
} |
pub fn SetValue(&mut self, _value: i32) -> ErrorResult {
Ok(()) | random_line_split |
htmllielement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLLIElementBinding;
use dom::bindings::utils::{DOMString, ErrorResult};
use dom::doc... | (&mut self, _type: DOMString) -> ErrorResult {
Ok(())
}
}
| SetType | identifier_name |
hello2.rs | //! # Basic Sample
//!
//! This sample demonstrates how to create a toplevel `window`, set its title, size and position, how to add a `button` to this `window` and how to connect signals with actions.
#![crate_type = "bin"]
extern crate gtk;
use gtk::prelude::*;
fn main() | window.add(&button);
window.show_all();
gtk::main();
} | {
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
return;
}
let window = gtk::Window::new(gtk::WindowType::Toplevel);
window.set_title("First GTK+ Program");
window.set_border_width(10);
window.set_position(gtk::WindowPosition::Center);
window.set_default_s... | identifier_body |
hello2.rs | //! # Basic Sample
//!
//! This sample demonstrates how to create a toplevel `window`, set its title, size and position, how to add a `button` to this `window` and how to connect signals with actions.
#![crate_type = "bin"]
extern crate gtk;
use gtk::prelude::*;
fn main() {
if gtk::init().is_err() {
pri... | } | gtk::main(); | random_line_split |
hello2.rs | //! # Basic Sample
//!
//! This sample demonstrates how to create a toplevel `window`, set its title, size and position, how to add a `button` to this `window` and how to connect signals with actions.
#![crate_type = "bin"]
extern crate gtk;
use gtk::prelude::*;
fn | () {
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
return;
}
let window = gtk::Window::new(gtk::WindowType::Toplevel);
window.set_title("First GTK+ Program");
window.set_border_width(10);
window.set_position(gtk::WindowPosition::Center);
window.set_defaul... | main | identifier_name |
hello2.rs | //! # Basic Sample
//!
//! This sample demonstrates how to create a toplevel `window`, set its title, size and position, how to add a `button` to this `window` and how to connect signals with actions.
#![crate_type = "bin"]
extern crate gtk;
use gtk::prelude::*;
fn main() {
if gtk::init().is_err() |
let window = gtk::Window::new(gtk::WindowType::Toplevel);
window.set_title("First GTK+ Program");
window.set_border_width(10);
window.set_position(gtk::WindowPosition::Center);
window.set_default_size(350, 70);
window.connect_delete_event(|_, _| {
gtk::main_quit();
Inhibit(fa... | {
println!("Failed to initialize GTK.");
return;
} | conditional_block |
vic_memory.rs | // This file is part of zinc64.
// Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved.
// Licensed under the GPLv3. See LICENSE file in the project root for full license text.
use zinc64_core::{Ram, Rom, Shared, SharedCell};
pub struct VicMemory {
base_address: SharedCell<u16>,
charset: Shared... |
pub fn read(&self, address: u16) -> u8 {
let full_address = self.base_address.get() | address;
let zone = full_address >> 12;
match zone {
0x01 => self.charset.borrow().read(full_address - 0x1000),
0x09 => self.charset.borrow().read(full_address - 0x9000),
... | {
VicMemory {
base_address,
charset,
ram,
}
} | identifier_body |
vic_memory.rs | // This file is part of zinc64.
// Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved.
// Licensed under the GPLv3. See LICENSE file in the project root for full license text.
use zinc64_core::{Ram, Rom, Shared, SharedCell};
pub struct VicMemory {
base_address: SharedCell<u16>,
charset: Shared... | }
}
} | random_line_split | |
vic_memory.rs | // This file is part of zinc64.
// Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved.
// Licensed under the GPLv3. See LICENSE file in the project root for full license text.
use zinc64_core::{Ram, Rom, Shared, SharedCell};
pub struct VicMemory {
base_address: SharedCell<u16>,
charset: Shared... | (base_address: SharedCell<u16>, charset: Shared<Rom>, ram: Shared<Ram>) -> VicMemory {
VicMemory {
base_address,
charset,
ram,
}
}
pub fn read(&self, address: u16) -> u8 {
let full_address = self.base_address.get() | address;
let zone = full_a... | new | identifier_name |
universe.rs | extern crate rand;
use std::vec::Vec;
use celestial::bodies::{Star, Planet};
use celestial::starsystem::{OrbitData, StarSystem};
pub struct Universe {
systems: Vec<StarSystem>
}
impl Universe {
pub fn generate() -> Universe {
let mut u = Universe{
systems: vec![]
};
// gen... | } | self.systems.get_mut(i).unwrap()
} | random_line_split |
universe.rs | extern crate rand;
use std::vec::Vec;
use celestial::bodies::{Star, Planet};
use celestial::starsystem::{OrbitData, StarSystem};
pub struct Universe {
systems: Vec<StarSystem>
}
impl Universe {
pub fn generate() -> Universe {
let mut u = Universe{
systems: vec![]
};
// gen... |
pub fn getSystem(&mut self, i: usize) -> &mut StarSystem {
self.systems.get_mut(i).unwrap()
}
}
| {
self.systems.len()
} | identifier_body |
universe.rs | extern crate rand;
use std::vec::Vec;
use celestial::bodies::{Star, Planet};
use celestial::starsystem::{OrbitData, StarSystem};
pub struct Universe {
systems: Vec<StarSystem>
}
impl Universe {
pub fn generate() -> Universe {
let mut u = Universe{
systems: vec![]
};
// gen... | (&self) -> usize {
self.systems.len()
}
pub fn getSystem(&mut self, i: usize) -> &mut StarSystem {
self.systems.get_mut(i).unwrap()
}
}
| numSystems | identifier_name |
p034.rs | //! [Problem 34](https://projecteuler.net/problem=34) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
fn compute() -> u32 {
let mut facts: [u32; 10] = [ 0; 10 ];
facts[0] = 1;
... |
problem!("40730", solve);
| {
compute().to_string()
} | identifier_body |
p034.rs | //! [Problem 34](https://projecteuler.net/problem=34) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
fn compute() -> u32 {
let mut facts: [u32; 10] = [ 0; 10 ];
facts[0] = 1;
... | () -> String {
compute().to_string()
}
problem!("40730", solve);
| solve | identifier_name |
p034.rs | //! [Problem 34](https://projecteuler.net/problem=34) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
fn compute() -> u32 {
let mut facts: [u32; 10] = [ 0; 10 ];
facts[0] = 1;
... |
problem!("40730", solve); | fn solve() -> String {
compute().to_string()
} | random_line_split |
p034.rs | //! [Problem 34](https://projecteuler.net/problem=34) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
fn compute() -> u32 {
let mut facts: [u32; 10] = [ 0; 10 ];
facts[0] = 1;
... |
}
answer - 1 - 2
}
fn solve() -> String {
compute().to_string()
}
problem!("40730", solve);
| {
answer += sum;
} | conditional_block |
io.rs | use std::os::raw::{c_char, c_void};
#[repr(C)]
pub enum LoadState {
Ok,
Fail,
Converted,
Truncated,
OutOfData,
}
#[repr(C)]
pub struct | {
pub priv_data: *mut c_void,
pub write_int: fn(priv_data: *mut c_void, data: i64),
pub write_double: fn(priv_data: *mut c_void, data: f64),
pub write_string: fn(priv_data: *mut c_void, data: *const c_char),
}
pub struct CPDLoadState {
pub priv_data: *mut c_void,
pub read_int: fn(priv_data: *m... | CPDSaveState | identifier_name |
io.rs | use std::os::raw::{c_char, c_void};
| Converted,
Truncated,
OutOfData,
}
#[repr(C)]
pub struct CPDSaveState {
pub priv_data: *mut c_void,
pub write_int: fn(priv_data: *mut c_void, data: i64),
pub write_double: fn(priv_data: *mut c_void, data: f64),
pub write_string: fn(priv_data: *mut c_void, data: *const c_char),
}
pub struct CPDLoadS... | #[repr(C)]
pub enum LoadState {
Ok,
Fail, | random_line_split |
kernels.rs | /*
* Copyright (C) 2013 The Android Open Source Project
*
* 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 app... | ushort3 us3i = {1, 2, 3};
ushort4 us4;
ushort4 us4i = {1, 2, 3, 4};
int i1;
int i1i = 1;
int2 i2;
int2 i2i = {1, 2};
int3 i3;
int3 i3i = {1, 2, 3};
int4 i4;
int4 i4i = {1, 2, 3, 4};
uint ui1;
uint ui1i = 1;
uint2 ui2;
uint2 ui2i = {1, 2};
uint3 ui3;
uint3 ui3i = {1, 2, 3};
uint4 ui4;
uint4 ui4i = {1, 2, 3, 4};
long ... | ushort3 us3; | random_line_split |
messages.rs | //! Protocol messages
//!
//! All protocol messages are serialized by serde according to the bincode data format. For
//! transmission on the wire, `tokio_io::codec::length_delimited` is used to prepend protocol
//! messages by an additional length header, thereby creating frames. It is crucial to
//!
//! The main type... | {
KeyExchange(KeyExchange),
DcExponential(DcExponential),
DcMain(DcMain),
Blame(Blame),
Confirm(Confirm),
Reveal(Reveal),
}
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct KeyExchange {
pub ke_pk: PublicKey,
}
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Dese... | Payload | identifier_name |
messages.rs | //! Protocol messages
//!
//! All protocol messages are serialized by serde according to the bincode data format. For
//! transmission on the wire, `tokio_io::codec::length_delimited` is used to prepend protocol
//! messages by an additional length header, thereby creating frames. It is crucial to | //! its contained types such as `Header` and `Payload` are public.
pub use secp256k1::key::{PublicKey, SecretKey};
use ::{SessionId, PeerIndex, SymmetricKey, SequenceNum, Commitment};
use dc::xor::XorVec;
use dc::fp::Fp;
/// A protocol message
///
/// Protocol messages consist of a header and a payload.
#[derive(Clo... | //!
//! The main type `Message` and the types in its fields are dump containers, which are not
//! responsible for any protocol logic (except for syntactic validation including validation of
//! `PublicKey` and `SecretKey` fields). Consequently, all fields of `Message` and all fields of | random_line_split |
issue-5708.rs | // Copyright 2013 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 ... | } | pub fn add (&mut self, foo: &'a MyTrait<T>) {
self.foos.push(foo);
} | random_line_split |
issue-5708.rs | // Copyright 2013 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 ... | () {
let inner = 5i;
let outer = Outer::new(&inner as &Inner);
outer.inner.print();
}
// minimal
trait MyTrait<T> { }
pub struct MyContainer<'a, T> {
foos: Vec<&'a MyTrait<T>+'a>,
}
impl<'a, T> MyContainer<'a, T> {
pub fn add (&mut self, foo: &'a MyTrait<T>) {
self.foos.push(foo);
}
... | main | identifier_name |
msub.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* 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... |
fn type_info(&self) -> ElementType {
ElementType::ScriptsAndLimits(ScriptsAndLimits::Msub)
}
fn as_any(&self) -> &Any {
self
}
fn as_any_mut(&mut self) -> &mut Any {
self
}
fn instance_id(&self) -> &InstanceId {
self.multiscript.instance_id()
}
}
imp... | {
self.multiscript.layout(context, family, inherited, style)
} | identifier_body |
msub.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* 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... | );
snapshot.snap_element(&msub, "msub_nested");
}
} | random_line_split | |
msub.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* 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... | (base: Box<Element>, subscript: Box<Element>) -> Msub {
let mut multiscript = Mmultiscripts::new(base);
multiscript.with_postscript(Mmultiscript {
subscript,
superscript: Box::new(Mempty::new()),
});
Msub {
multiscript,
}
}
pub fn wit... | new | identifier_name |
user.rs | /*
* The user represents a structure that can receive data from or send data to a certain user that
* the program is currently connected to.
*/
use std::io::prelude::*;
use std::net::{TcpStream, SocketAddr};
use std::thread;
pub struct User {
stream: TcpStream,
}
impl User {
pub fn new(stream: TcpStream) -> Us... | }
} | random_line_split | |
user.rs | /*
* The user represents a structure that can receive data from or send data to a certain user that
* the program is currently connected to.
*/
use std::io::prelude::*;
use std::net::{TcpStream, SocketAddr};
use std::thread;
pub struct User {
stream: TcpStream,
}
impl User {
pub fn new(stream: TcpStream) -> Us... |
fn receive_messages(stream: &mut TcpStream) {
loop {
let mut data = vec![0; 128];
let size = match stream.read(&mut data) {
Ok(size) => size,
Err(err) => {
println!("{:?} has been closed due to: {}", stream, err);
break
}
};
if size == 0 {
println!("{} disconnected.", stream... | {
let user = User {
stream: stream,
};
let mut receive_stream = user.stream.try_clone().unwrap();
thread::spawn(move || {
User::receive_messages(&mut receive_stream);
});
user
} | identifier_body |
user.rs | /*
* The user represents a structure that can receive data from or send data to a certain user that
* the program is currently connected to.
*/
use std::io::prelude::*;
use std::net::{TcpStream, SocketAddr};
use std::thread;
pub struct User {
stream: TcpStream,
}
impl User {
pub fn new(stream: TcpStream) -> Us... | (stream: &mut TcpStream) {
loop {
let mut data = vec![0; 128];
let size = match stream.read(&mut data) {
Ok(size) => size,
Err(err) => {
println!("{:?} has been closed due to: {}", stream, err);
break
}
};
if size == 0 {
println!("{} disconnected.", stream.peer_addr().unwrap())... | receive_messages | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Servo's compiler plugin/macro crate
//!
//! Attributes this crate provides:
//!
//! - `#[derive(DenyPublicFie... | {
reg.register_late_lint_pass(Box::new(unrooted_must_root::UnrootedPass::new()));
reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted);
reg.register_attribute("must_root".to_string(), Whitelisted);
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.